SDL_net_demos
- Size
- 1.0M (1,073,792 bytes)
- Added
- 2026-11-20 02:44
- Downloads
- 2
- Long Description
- Visit http://www.jonatkins.org IKE Original Readme: ABOUT ~~~~~ These are some simple programs that demonstrate how to program using SDL_net. COMPILATION ~~~~~~~~~~~ run "make" THE PROGRAMS ~~~~~~~~~~~~ dnr.c demonstrates: Host Name and IP lookup, and initialization of the IPaddress struct SDLNet_ResolveHost SDLNet_ResolveIP try: ./dnr 24.8.116.27 ./dnr jonatkins.org tcpserver.c demonstrates: A TCP message server SDLNet_ResolveHost (for a server) SDLNet_TCP_Open SDLNet_TCP_Accept SDLNet_TCP_GetPeerAddress SDLNet_TCP_Recv SDLNet_TCP_Close try: ./tcpserver 9999 usage: Run as above... Then run tcpclient as shown below. The tcpclient entered string should show up here when received. This server will accept multiple sucessive connections, until it quits. tcpclient.c demonstrates: A TCP client for tcpserver SDLNet_ResolveHost (for a client) SDLNet_TCP_Open SDLNet_TCP_Send SDLNet_TCP_Close try: ./tcpclient localhost 9999 usage: Enter a string, or Q to make the tcpserver quit. You may call this from another host using the servers hostname instead of localhost. This should be able to be called multiple times until you make the server quit. tcpmultiserver.c demonstrates: A TCP chat server that allows multiple clients to connect This is actually a feature full server, supporting some /commands SDLNet_SocketSet (all functions, except SDLNet_DelSocket's) try: ./tcpmultiserver 9999 usage: Run as above... Then run tcpmulticlient as shown below. The tcpclient entered string should show up here when received. The client's strings should also be forwarded to all connected clients. Joins and disconnects will be reported to all clients, as well as on the server. This server will accept multiple connections in parallel, until it is killed. tcpmulticlient.c demonstrates: A TCP client for the tcpmultiserver Also a suitable system for text input while reading a socket. SDLNet_SocketSet (just for one socket) select (for keyboard input) try: ./tcpmulticlient localhost 9999 Klonkus ./tcpmulticlient localhost 9999 Frumpy usage: Run the tcpmultiserver as shown above... Then run both the above command lines. You should see both clients connect to the server. Now you can enter messages in each window (press enter) The messages will be distributed to the server, and then back to the clients. Type /help for the commands the server supports... Type /quit and an optional message to quit Press Control-C (or EOF[Control-D] if you want) to quit harder tcpmulticlientthreaded.c demonstrates: same as tcpmulticlient.c plus: SDL_Threads are used for all I/O try: usage: (See the tcpmulticlient.c stuff above!) tcptimesync.c demonstrates: simple TCP reading and writing time syncronization in 5 packets try: ./tcptimesync 0 7777 & ./tcptimesync 500 7777 localhost usage: tcptimesync lag port [hostname] if hostname is not given, the server is started lag is the desired simulated lag time in milliseconds the lag argument is ignored in server mode run the first line above to start the server run the second line above to connect and do a time syncronization it should settle on a lag close to 500 but the important thing is that the client time is close to the time the server has...and this is hard to show across the internet. (note: more in