Socket Examples
Prof. Drake's
Networking and Sockets page
The following are some simple TCP socket examples.
- This client/server pair runs a simple TCP socket program
as an Echo Server
that only allows one client to connect to the server.
- This client/server pair improves on the previous Echo
Server that allows multiple clients to connect to the server.
- This server improves on the previous Echo Server since it
allows the "connection thread" of the server to stop executing
via a command sent from the client.
- This server improves on the previous Echo Server since it
uses a time out on the server's connection TCP socket to continuously
check if it should stop the "connection thread" of the server
from executing.
- This example shows how to send an object across a TCP socket
by serializing a class.
- This is a example of a extremely simple web server.
The client is a web browser.
The following are some simple UDP socket examples.
- This client/server pair runs a simple UDP socket program
as an Echo/Uppercase Server
that only allows the client to send one message to the server.
- This client sends multiple messages to the Echo/Uppercase
Server to check if packets get dropped.
- This program scans the UDP ports on the local machine to
see if they are being used.
These examples were written very quickly and currently
are under-commented.