As part of one of my projects at work that needs TCP communication, I decided to build my own TCP server/client pair. I tried to build it so that it is fairly self-managed, easy to implement into network projects, and contains a lot of useful inbuilt metrics.
Supported metrics (supported both server and client side):
- Number of current connections
- Client and server connection test
- Bytes sent / received / processed
- Packets sent / received / processed
- Number of clients connected
- Sockets / IP address / computer name
- Connection timestamp / elapsed time
- Last packet received timestamp / elapsed time
- Last packet sent timestamp / elapsed time
Functionality (on top of standard TCP functions):
- Configurable to send an initial "connection packet" upon connection, client or server-side.
- Connection keep-alive packets at specific intervals
- "Stale" connection disconnects for old, idle connections
- Selective client broadcasting. On the server, clients can be individually selected to rebroadcast data received from them.
- Automatic IP/socket/computer name detection
- Connection state change detection. e.g. This facilitates updating a GUI connection list when clients have connected or disconnected.
I would appreciate your constructive comments and suggestions.
I am including the UDF, and sample server and client.
Routines_TCP.au3 TCP Server.au3 TCP Client.au3