October 2, 2011
I recently was complaining about how complicated socket programming was in C - so in an effort to help my future self, I created a little wrapper around connecting and binding sockets in C.
To bind a socket to all interfaces via TCP on port 8080:
int s = connection_bind("tcp://:8080");
To bind a socket to the local interface via TCP on port 8080:
int s = connection_bind("tcp://localhost:8080");
To connect to www.codefall.com on port 80:
int s = connection_connect("tcp://www.codefall.com:80");
UDP works too:
int s = connection_bind("udp://:8080");