Library recommendation?

This is a discussion on Library recommendation? within the Networking/Device Communication forums, part of the General Programming Boards category; Hi. I'm looking for a fairly basic, cross-platform, easy to use sockets library. When I say cross-platform, I really only ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Location
    Melbourne, Australia
    Posts
    92

    Arrow Library recommendation?

    Hi.

    I'm looking for a fairly basic, cross-platform, easy to use sockets library. When I say cross-platform, I really only care about Windows and Linux/BSD; I don't care about supporting all sorts of really obscure platforms at this point...

    It's for a multiplayer game, the networking of which should be relatively simple (as opposed to the actual game logic, which thankfully I've got figured out just fine...). I've heard that OpenSSL has a subset of more basic functions for those who don't want its full functionality, but I'm wondering if it's worth forcing users to have it (especially Windows users who are unlikely to have it already) if I'm only using a tiny bit of it.

    Are there one or more popular libraries that are generally considered the 'standard' one[s] to use for something like this? I'm writing the game in C++, so obviously a C library would be fine, but if there's one written in C++ and/or handles threading (I'll be wanting multiple clients connected at a time, so I presume I'll need to do something about that) and does some other funky stuff to make using it cleaner/easier then that would be preferred.

    Any comments or suggestions appreciated!

    Cheers!
    Last edited by PsychoBrat; 02-09-2006 at 12:06 AM.
    psychobrat at gmail

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Try checking out www.wxwindows.org
    It's a cross-platform GUI library, but it does include a base (non GUI) called wxBase where it utilizes cross-platform sockets, files, etc. I don't know if it would work on BSD, but I don't see why there would be a problem.

    There is also http://www.gnu.org/software/commoncpp/
    Don't know anything about it, but it just proves I'm a better searcher than you.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Socket programming on windows isn't that different from Linux. A few #ifdef's here and there would do it.

  4. #4
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Quantum - That's true, but not with asynchronous sockets, right? I've never done linux programming at all, but I would think if using asynchronous sockets, for cross-platform-ism you would need more than a few #ifdef's. But if using regular blocking/nonblocking sockets then a few #ifdef's would work.

    Am I right in thinking that?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  5. #5
    Registered User
    Join Date
    Aug 2001
    Location
    Melbourne, Australia
    Posts
    92
    Quote Originally Posted by Quantum1024
    Socket programming on windows isn't that different from Linux. A few #ifdef's here and there would do it.
    I think I'll take that option, then.

    neandrake: what's the distinction between regular non-blocking sockets and asynchronous sockets?

    Thanks
    psychobrat at gmail

  6. #6
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    PsychoBrat - Non-blocking have to be handled with threads in order to work with multiple connections. Well you don't need threads, but you have to manually check on sockets. Asynchronous sockets use window's messaging system in order to deal with them. I've used asynchronous sockets way more than any other so I'm more familiar with it.

    Quote Originally Posted by Johnnie's Winsock Tutorial
    A non-blocking socket returns immediately whenever it is told to do something, either with a successful result, an error, or nothing (indicating that there will be something to receive later). The disadvantage of using this type is that you'll have to manually query the socket to see if a result has come in on every function you call. You can pass a set of sockets to the select() function to see which ones are ready for reading, writing, or have returned errors.

    Functions using asynchronous sockets also return immediately, but you can specify a message to send to your window procedure when a specified event has occurred.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  7. #7
    Registered User
    Join Date
    Aug 2001
    Location
    Melbourne, Australia
    Posts
    92
    Thanks

    I think I'll stick to regular non-blocking sockets w/ threads.

    (and thanks to everyone else for their input )
    psychobrat at gmail

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by neandrake
    Quantum - That's true, but not with asynchronous sockets, right? I've never done linux programming at all, but I would think if using asynchronous sockets, for cross-platform-ism you would need more than a few #ifdef's. But if using regular blocking/nonblocking sockets then a few #ifdef's would work.

    Am I right in thinking that?
    I believe you're correct about asynchronous sockets at least when using windows messaging. I was thinking of regular blocking/nonblocking sockets when I wrote my post and hadn't even considered asynchronous sockets use of windows messaging.

    Select() exists on both platforms so on linux I think you'd need to write your own WSAAyncSelect() function to check sockets and output messages. But then you don't have to stick to the windows paradigm to create an asynchronous socket application.
    Last edited by Quantum1024; 02-17-2006 at 06:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 06:04 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 12:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21