dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Porting socket program from Linux to Windows

  1. #1
    Join Date
    Oct 2009
    Posts
    56

    Porting socket program from Linux to Windows

    I have a project that uses BSD sockets in linux. I want it to also run in Windows. From what I gathered, I need to have conditional compiling and use Winsocks. Is there any other way I can do this? It seems unnecessary and bad coding practice to have large chunks of code for bsd sockets and then more large chunks, doing essentially the same thing, for winsocks. I am using MinGw and do not wish to use Cygwin. Any help is appreciated.

  2. #2
    Join Date
    Oct 2009
    Posts
    56

    Re: Porting socket program from Linux to Windows

    Well, I just did it anyway and there was definitely not large chunks of code added. Its basically the same thing.

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Porting socket program from Linux to Windows

    Quote Originally Posted by SterlingM View Post
    Well, I just did it anyway and there was definitely not large chunks of code added. Its basically the same thing.
    As you discovered, if you have working BSD code in Linux, it's fairly easy to port to Windows. There are very few conditional compilation switches, and only a few "oddities", like the need in Windows to call WSAStartup and WSACleanup, and the change in function name from Unix’s ioctl() and close() to Winsock’s ioctlsocket() and closesocket()

    A few other issues are noted at http://tangentsoft.net/wskfaq/articl...atibility.html

    In addition, there's a section in the Winsock documentation that describes proting from Unix/Linux to Windows:
    - "Porting Socket Applications to Winsock" at http://msdn.microsoft.com/en-us/library/ms740096
    - "Windows Sockets 2 Application Programming Interface", section 3.1 - "Deviation from BSD Sockets" at ftp://ftp.microsoft.com/bussys/winso...k2/WSAPI22.DOC

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)