Skip to content

andy5995/c_networking_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C/C++ CI

C Networking Examples

TCP and UDP examples of networking in C

Website: https://github.com/andy5995/c_networking_examples

TCP SDL Window Updater server and client

When you connect to the server with the client, a window rendered with sdl will be created. Clicking in the client or server window will move a geometric shape to the coordinates where you clicked.

Dual Stack Echo Server

The server listens for connections on both ipv4 and ipv6 addresses. To test, run the server, and in a different window, enter in either of the following:

./dual_stack_echo_client 127.0.0.1
./dual_stack_echo client ::1

TCP File Transfer

Transfer a plain text or binary file of any size from the client to the server

TCP Chat

Simple chat program

TCP Chat server with multiple connections

Handles multiple connections. The server will tell you when clients connect and disconnect. Every client will see the message sent by any other single client. Use any telnet program to connect.

Adapted from pollserver.c

UDP echo server/client

The server echoes a message sent by the client back to the client.

client usage: ./udp_echo_client host port msg...
server usage: ./udp_echo_server port

Additional Information

Unless otherwise specified, the clients in these examples use "127.0.0.1" for the address and port 8080 as the defaults, but they can be changed at runtime:

-a <address>
-p <port>

The servers will most likely bind to "0.0.0.0" and there's no option to change that yet.

Compiling

meson builddir
cd builddir
ninja

See Also