Know of any cross platform socket library (windows & Linux) in C?
Off-hand, I can think of four libraries:
GLib Channels from the GLib framework can abstract socket usage, but you'll need platform-specific code for socket creation.
libuv is a platform abstraction layer for node.js and handles, among other things, sockets and async IO.
The Apache Portable Runtime also contains network routines.
The Netscape Portable Runtime does socket manipulation as well.
The plibsys library provides all the requested features: cross-platform and portable, lightweight, provides socket IPv4 and IPv6 support as well as many other useful things like multithreading. Works with sockets in non-blocking mode (though you can switch to a blocking one, too). Has quite a good documentation with the test code examples.
I don't know one library that complies both Windows and Linux but I think winsock
is similar enough to Linux socket programming.
In particular it supplies you 'select()' and the other functions mentioned. I guess you will need a very thin #ifdef wrapper to avoid type casting warnings.