Both Windows and Unix-style platforms offer Berkeley Sockets APIs, but Windows implementation has some differences, e.g. the use of WSAStartup()
and WSACleanup()
functions. Other than that, a few #ifdef
s and the application will compile on both platforms without any problems. Assuming it's supposed to be a simple command-line app of course.
There's a section Porting Socket Applications to Winsock on MSDN. All you have to do is to work backwards. ;)
Also read a book on socket programming, for example Beej's Guide to Network Programming.
Another option is to use Boost::Asio. This hides any sockets API differences very smoothly.