CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    cross platform sockets

    Hi
    I want to make a simple application that uses sockets.
    This application should be cross platform (mainly should run on Windows / redhat Linux/ fedora) ..Or at least it should be ported easly...
    What socket libraries should I use ? can BSD sockets work for both platforms ?
    Or must I wirte the windows version using winsock ?
    Any suggestions / comments are welcome...
    Last edited by hspc; March 18th, 2005 at 08:29 AM.
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: cross platform sockets

    I actually suggest using the pre-processor for this.

    You can :
    Code:
    #define MSWINDOWS 1
    and later:

    #ifdef MSWINDOWS
    //winsock only needed for windows, not free BSD or LINUX
    #pragma comment (lib, "ws2_32.lib")
    #endif
    using different #defines for different builds. In other words you can use seperate verbose for each OS yet in the same file with partially the same code. Just use #ifdefs where the syntax differrs.

    This way you can maintain one codebase for your cross platform application.

    HTH,

    ahoodin

    PS Don't forget to rate.
    Last edited by ahoodin; March 18th, 2005 at 09:24 AM. Reason: added in last comment

  3. #3
    Join Date
    Feb 2002
    Posts
    5,757

    Re: cross platform sockets

    I am not familiar with the Berkeley Socket. I do know a cross-platform C++ library though. Check out Trolltech's Qt.

    Kuphryn

  4. #4
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: cross platform sockets

    Hi
    As far as I know..Qt is a cross platform GUI library.
    I don't think it contains sockets.
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: cross platform sockets

    Well...as long as you use raw windows sockets (not the MFC wrappers etc.) you are fine. You simply need to link the appropriate library depending on the system.

    Other than that you might want to take a look at the ACE framework...

  6. #6
    Join Date
    Feb 2002
    Posts
    5,757

    Re: cross platform sockets

    Check out Qt's QSocket.

    Kuphryn

  7. #7
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: cross platform sockets

    Quote Originally Posted by Andreas Masur
    Well...as long as you use raw windows sockets (not the MFC wrappers etc.) you are fine. You simply need to link the appropriate library depending on the system.
    Great..
    seems I'm going to use this way
    thanks
    Last edited by hspc; March 19th, 2005 at 03:29 PM.
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured