I'm having a code written in C that works on Linux. I want this program to work in windows, A开发者_开发百科re there any differences that I have to make in the code ?
It is a code for Server/Client communication using sockets taken from here : http://www.linuxhowtos.org/C_C++/socket.htm
You can compile your code under Cygwin or MINGW, both of which provide a certain degree of Linux-system-call-to-Windows-system-call-mapping, and you may avoid having to rewrite anything at all.
You will have to port the Linux code to Windows. There are differences between Linux and Windows sockets. You can check out this page for further information.
Also, this will help you with some of the porting.
Looking briefly at that article that you refer to reveals a few things that will likely need to change (assuming you are going to use something like Visual Studio to build it):
- Replace
read
withrecv
- Replace
write
withsend
- Replace
bzero
withmemset
- Add calls to
WSAStartup
andWSAShutdown
Lots! Mark said it best it seems. recv and send still work however to a file descriptor. THe worst part is lack of GNU features like timeval struct without going through horrible windows includes.
精彩评论