lapbConn()
PROTOTYPE
#include <lapb.h>
int lapbConn(uint channel);
DESCRIPTION
lapbConn() establishes or reestablishes a LAPB connection for the channel specified by channel, which must be in the range from 0 to LAPB_MAX_NUM_CHANNELS - 1 and correspond to a registered HDLC channel. If the channel is already connected when lapbConn() is called, the call succeeds and returns immediately.
If the channel is physically disconnected, lapbConn() calls the HDLC frame driver’s connect() routine to physically connect the channel. Depending on the driver, this may assert line control signals and/or start clock signals. If the HDLC connect() fails, lapbConn() also fails, setting errno to the error code returned by the driver.
After the channel is physically connected, it begins sending either DM responses with F=0 (in passive mode) or SABM/SABME commands at intervals of T1 tenths of a second. lapbConn() blocks until a SABM/SABME command is either accepted by a UA response or rejected by a DM response, N2 SABM/SABME commands have gone unacknowledged, or a DISC command is received from the remote peer.
If successful, lapbConn() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| LAPB_INPROGRESS | A previous lapbConn() or lapbDisc() call is inprogress. |
| LAPB_INVALID_CHAN | channel is not a registered channel in the range from 0 to LAPB_MAX_NUM_CHANNELS - 1. |
| LAPB_NOT_CONNECTED | LapbConnect() did not succeed in making a connection. |
| LAPB_UNINITIALIZED | The initialization routine lapbInit() has not been called. |
| LAPB_WOULDBLOCK | A connection has been initiated, but the channel is non-blocking. |
| LAPB_NOCONFIG | The channel has not been configured using lapbConfig(). |
EXAMPLE
/*-----------------------------------------------------------------*/
/* Connect the channel. */
/*-----------------------------------------------------------------*/
do
rc = lapbConn(CHANNEL);
while (rc);
Connected = TRUE;