0

I have write a game on OpenGl, and want to make it a multiplayer game. I'm working on Windows, but I'm actually a C#-programmer. Socket programming goes too easy at C#, but at c++ I can not solve it :(

Which library should I use? winsock and winsock2 libraries are too complicated. Is there any library easy to use like in C# System.Net.Sockets ?

Kind Regards.

7 Answers 7

4

Beej's Guide to Network Programming is recommended in a number of SO replies, for example binding-a-socket-to-port-80-in-ansi-c. Try going over the examples, and maybe you'll find that it's not "too complicated". Windows winsock is highly compatible with the standard socket library. The tutorial contains instructions for programming sockets under Windows.

Sign up to request clarification or add additional context in comments.

1 Comment

Agreed - it's a bit naive for Cmptrbto assume that existing libraries are too complicated when it appears they haven't done much investigation.
4

Have a look at the ACE framework. It exists for quite some time.

4 Comments

I've used ACE framework and its quite useful. Use the link the previous poster gave. Easy to absorb if you know what you want to get out of it.
It's too big for what it needs to do in games.
The OP can decide this after having a look. I admit it is pretty big.
For C++ network programming, I think ACE is the best. ACE comes with a lot of different libraries. But, the core library has TCP and UDP classes that are pretty easy to use. The book ACE network programming gives good explanation and examples of simple uses of these classes. amazon.com/ACE-Programmers-Guide-Practical-Programming/dp/…
3

The Boost.Asio library is also quite good.

Comments

1

I haven't tried any of these. How about SDL_net or Qt?

Read about QSocket in the qt documentation.

Comments

1

If you're looking for a simple wrapper to make Socket programming nicely object-oriented, you might check out the sockets wrapper layer I wrote as part of my cross-platform messaging library. It would be pretty straightforward to rip that code out and re-use it. You might even be interested in the rest of the library as well.

Comments

0

You can take a look a the networking sections of the Poco libraries. They aren't going to necessarily be like C# but they are OOP oriented and insulate you as much as possible from the details of network programming. They are also cross-platform is that is an issue.

[Obligatory note that you should probably expose yourself to said details at some point.]

Comments

0

You should look into Raknet if you're intrested in Networking for games; or Winsock/BSD sockets if you really want to learn everything under the hood!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.