views:

132

answers:

4

I'm having a code written in C that works on Linux. I want this program to work in windows, Are 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

+1  A: 

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.

Secko
+2  A: 

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.

Conspicuous Compiler
True! However, sometimes the code has to be prepared in order to compile on Cygwin, and some socket programming statements are unsupported.
Secko
+1  A: 

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 with recv
  • Replace write with send
  • Replace bzero with memset
  • Add calls to WSAStartup and WSAShutdown
Mark Wilkins
A: 

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.

Bryan C