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
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With