
Chapter 15 – Raw TCP/UDP Socket Interface to the Serial Device
Command Line Interface and Application Examples for Multi-Tech Systems, Inc. IP Modules (S000368F) 149
Scenario 4 – Setting up TCP Sessions and IP
Module Acting as Server
Start a TCP server to keep listening on a particular port. When a connection is accepted from a remote host, a socket
handle is created. This can be used to send and receive data to and from that remote host.
Command
socket tcplisten <local_port> [backlog]
Example
The tcplisten command on success returns a server socket handle.
#socket tcplisten 3000
Tcp Listen socket handle 4
OK
#
This doesn't create any listen sockets. The listen sockets are created when a remote host tries to connect to the IP
Module and the connections are accepted by IP Module.
#socket listlisten
Tcp Server Handle: 4
Local Port: 3000
Backlog: 10
No TCP listen sockets
OK
#
After accepting connections from remote hosts the sockets list is updated.
#socket listlisten
Tcp Server Handle: 4
Local Port: 3000
Backlog: 10
SockHandle SockType RemoteIP RemotePort LocalIP LocalPort
5 TCP listen 192.168.1.120 3072 192.168.1.144 3000
OK
#
Notes
1. Tcplisten with backlog allows you to limit the number of connections to a TCP server by specifying the
backlog parameter. By default the backlog is 10.
2. We can issue any socket command any time depending on the requirement.
Kommentare zu diesen Handbüchern