OS independent Socket API

Started by
7 comments, last by Alpha_ProgDes 15 years, 10 months ago
Can anyone reccomend OS independent(works on Win, Linux, ...) Socket API, what has Winsock2 completition features.
http://www.daily-it.com
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.
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..
www.ageofconan.com
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.
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
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.
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.
enum Bool { True, False, FileNotFound };
Im going to use TCP sockets. But why not make own IO model based on Berkley sockets?
http://www.daily-it.com
RakNet?

Beginner in Game Development?  Read here. And read here.

 

This topic is closed to new replies.

Advertisement