Testing TCP / UDP clients and servers with a Linux platform
Sometimes you need a quick method or mechanism to test either a TCP or UDP client or server works, this can be done with the Linux netcat application. Some examples of this application usage are :-
Show Plain Text- netcat -ul -p3500
This will listen for UDP packets on port 3500 of the Linux machine i.e. server.
Show Plain Text- netcat -u localhost 3500
This will act as a UDP client on port 3500. On both the client and server you can type text messages and hit
- netcat -l -p 3500
This will listen for TCP packets on port 3500 as a server process.
Show Plain Text- netcat localhost 3500
This will act as a TCP client on port 3500. You could also use the telnet command.
Its also quite useful to figure out what processes are on your TCP or UDP ports. The netstat application is great for this.
Show Plain Text- netstat -ntpl
This will list all of your TCP ports that are open.
Show Plain Text- netstat -nupl
This will list all of your UDP ports that are open.
To send a test UDP packet to a server you can use :-
Show Plain Text- echo -n "foo" | nc -u -w1 localhost 3500