COMM-DRV/Lib: ModemConnect() Returns true if modem connection attained

Description-

Returns true if the modem connection was successful. This call is generally made after a call to Dial() if programmer is initiating a session. Otherwise it may be called simply to detect when the modem has successfully connected to another modem. It first scans for the message “CONNECT” (or the connect token set with the ModemModifyString() function) from the port. If it does not get it will check to see if the carrier detect signal is present. If the “CONNECT” string or the carrier detect signal is present then it assumes that the modem is connected to another modem and returns successful. The modem is in the online state after this function returns.

Note: After some modems connect, they switch to the carrier speed(baud rate between two modems over the telephone line). As an example, if you are connected to your modem at 9600 baud(baud rate between the computer and the modem), and it connects to a 2400 baud modem, after it connects, and sends the connect message, the modem may switch its baud to 2400. If a modem of this type is used, the programmer must then change the baud to 2400 baud with the SetBaud() function. The carrier speed may be queried with the ModemGetCarrierSpeed().

Syntax-

stat = ModemConnect(port);;

On Entry-

int port;

Port previously opened with InitializePort() or OpenComPort().

On Exit-

int stat;

0 If successful.

else

-1 If port was not initialized.

-2 If modem not responding.

-3 If no dial tone

-4 If number dialed is busy.

See Also-

Dial()
ModemAnswerMode()
ModemAttention()
ModemGetCarrierSpeed()
ModemGetConnectSpeed()
ModemHangup()
ModemInit()
ModemModifyString()

Example-

#include "comm.h"
int port=0;
int stat;
int mode=1;
char *telephone="1-713-568-6401";
if ((stat = ModemInit(port)) == -1)
 {
 printf("Error getting modem's attention.\n");
 /* Take remedial action */
 }
if ((stat = Dial(port,mode,telephone)) == -1)
 {
 printf("Modem not responding\n");
 /* Take corrective action */
 }
if ((stat = (ModemConnect(port)) != 0)
 {
 switch(stat)
   {
   case -1:
   printf("Port not initialized .\n");
   break;
   case -2:
   printf("Modem not responding .\n");
   break;
   case -3:
   printf("No Dial Tone.\n");
   break;
   case -4:
   printf("Line Busy .\n");
   break;
   default:
   break;
   }
/* Take remedial action */
 }