Search code examples
windowslinuxsocketswinsockporting

Porting Winsock to Linux Sockets


I have a program that does some networking using Winsock, and one of our requirements right now is to port over our program to Linux. The only thing stopping us from doing this is Winsock.

My question is: How easy can I port this over to a Linux implementation?

Are there any pitfalls I should be aware of, and if I simply include the appropriate header files, what sort of things will I have to be sure to handle?

Thanks for any help!

I'd post code but I can't unfortunately due to legal reasons. But, our code does use the following:

WSAStartup(..)
WSACleanup(..)
Socket(..)
sendto(..)
recvfrom(..)
ioctlsocket(..)
setsocketopt(..)

Solution

  • It will depend if you use any windows specific networking functionality or if you're just using mostly the mostly BSD compatible API.

    So, if you're using overlapped I/O and I/O completion ports and other advanced parts of the Winsock API then things will be very difficult to port and if you're just using the BSD compatible stuff then it should be easy to write a thin translation layer or even just have the winsock startup and shutdown stuff inside a windows specific ifdef...

    This may help: http://tangentsoft.net/wskfaq/articles/bsd-compatibility.html