Getting status of DCE device from a DTE device

Leslie Mikesell les at chinet.chi.il.us
Tue Apr 30 07:13:45 AEST 1991


In article <8283 at alpha.cam.nist.gov> coleman at cam.nist.gov (Sean Sheridan Coleman X5672) writes:
>Is there a way from inside a C program to find out if
>DATA CARRIER DETECT is high on the Data communication devices?

>I want my program to see if there is a modem device on the
>other end of the cable before it tries to use that port.
>I am trying to make sure that the port plugged into the 
>back of my Sparc Station is hooked into something.

First of all, a modem should not be asserting carrier detect
unless it has a connection up with another modem.  If you
set it to keep carrier detect up all the time, then you can't
tell when you actually have a connection. 

To test for carrier detect being asserted, all you have to do is
set a short alarm and attempt an open.  If the alarm hits before
the open completes, you were blocked waiting for CD.  Or, with
Suns you can open with O_NDELAY and use their ioctl() extensions
to retreive the modem status.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.wizards mailing list