Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect incoming connections in my modem

Tags:

c#

I need to detect when someone is connected to my computer. I have an incoming connection enabled, and need to know when a user is connected. Preferably from a script in CSharp

like image 652
Rolando Rodriguez Ortega Avatar asked Apr 29 '11 05:04

Rolando Rodriguez Ortega


1 Answers

Generally, regardless of language, the approach is to open a serial port to talk to the modem. For .NET, you might want to refer to System.IO.Ports.SerialPort. The connection parameters (baud rate, data bits, stop bits, parity, flow control) depends on the device in question. Try 57600 or the fastest speed of your serial port, 8 databits, 1 stop bit, no parity and hardware flow control; that's what's typically used.

Hayes compatible modems spend "RING" notifications (plan text) over a serial port when someone is dialling. You'd send an "AT A" to the modem to anwer the call (or the modem may be configured for auto answer). When a connection is established, a "CONNECT XXX" is sent from the modem, where XXX is the connection details. For a summary of Hayes commands, see this Wikipedia link. (It also describes details such as command/data mode that you'll probably need to go into, if you want to program communications over a modem connection.)

like image 71
Cumbayah Avatar answered Dec 11 '22 13:12

Cumbayah