Jump to content
  • Advertisement
Sign in to follow this  
TiitHns

OS independent Socket API

This topic is 3821 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone reccomend OS independent(works on Win, Linux, ...) Socket API, what has Winsock2 completition features.

Share this post


Link to post
Share on other sites
Advertisement
There is none: Winsock2.

You can look at forum FAQ (or google) for boost ASIO, libasync or ACE, which provide equivalent cross-platform functionality.

Share this post


Link to post
Share on other sites
ACE

http://www.cs.wustl.edu/~schmidt/ACE.html

Good things:
- ACE has been around for ages, *core* of it seems to be solid.
- Has objects for most things like inet adresses/sockets/etc.

Bad stuff:
- Documentation sucks (online). You need books to get decent info out.
- The newer reactors (epoll) have features that doesnt work at all. documentation is wrong, claiming that return values is doing one thing while in reality (if you look at the code) its doing something else. (this confusion is mainly for -1 and non zero values)
- You get the entire thing and its doing a lot more than just network.
- Manual ref counting for objects

We've used ACE for these games in Funcom.
- Anarchy Online
- Age of Conan


QT has wrappers for socket functionallity (as well as GUI and a lot of other stuff). I havent really tried it (network), I dont know how it scales, but i've looked at their API's, and they look freaking sexy :D

If you're doing open source or can afford the license i would try QT before i tried ace..

Share this post


Link to post
Share on other sites
It may not be the best approach, but doesn't Berkely sockets API have an 98% equivalent API in Winsock2?

Meaning you can write the same Berkley sockets code for both platforms, with the only exception of including "winsock2.h" on Windows and some other headers on Linux.

Also, you need to call WSAStartup() before using it on Windows (but not Linux), and use close() instead of closesocket() on Linux.

Share this post


Link to post
Share on other sites
Quote:
Original post by shurcool
It may not be the best approach, but doesn't Berkely sockets API have an 98% equivalent API in Winsock2?

Meaning you can write the same Berkley sockets code for both platforms, with the only exception of including "winsock2.h" on Windows and some other headers on Linux.

Also, you need to call WSAStartup() before using it on Windows (but not Linux), and use close() instead of closesocket() on Linux.


Yeah. I've used this approach in the pass. It's pretty trivial to write a wrapper class that works cross platform with only a few #ifdef WIN32 #else #endif blocks

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by shurcool
It may not be the best approach, but doesn't Berkely sockets API have an 98% equivalent API in Winsock2?

No, there isn't one:
Quote:
has Winsock2 completition

IOCP is windows specific, *nix variants use different event-based systems.

Share this post


Link to post
Share on other sites
For general sockets development, it's quite straightforward to set up a few #defines that make your code work and look the same on UNIX, MacOS and Windows. This works fine up to active sockets (as you will need to use select()).

For larger numbers of sockets (which means more than 64 clients using TCP), you'll have to go spelunking. Some people recommend ACE, but I'm personally not that keen on it. Others recommend boost::asio, which is a high-performance asynchronous I/O library that happens to also work with sockets, in a cross-platform manner.

If you're using UDP, you won't need more than one socket, so any cross-platform library is going to be largely useless.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!