views:

1414

answers:

5

I'll be quick and honest: I'm currently trying to write a client/server for an online game. Since I'm poor and limited on resources, I'll be testing the bare basics of the server using a PHP backend, with the eventual goal being to rebuild the server end in C++.

I'm looking for a C++ library for Windows (XP and Vista preferably) that will let me use a finite number of threads, one dedicated to each piece of the networking problem. As an example, I want to use a thread to report the positional information of the player to the server (and to receive responses about positional information of the other players) but I want a different thread to background download in the 3D artwork for the area/players, and a different thread for the built in chat system, etc. These all need to be fairly independent of one another.

I know what I want to do with the library, I've got the design bit figured out, I just feel a bit silly re-inventing the wheel, since I know that a good library for this exact purpose probably already exists. So, what are your suggestions? I need to be able to send data to a server, and accept responses. Ideally, the request needs to trigger an Event when its done (so I can immediately grab the data and do something with it) and I need to be able to handle multiple transactions simultaneously. HTTP is a nice bonus, but I can handle HTTP protocol myself if necessary, especially considering that I plan on dropping it in the long run.

Thanks!

+1  A: 

Check out the Boost libraries, in particular, Boost Threads.

tvanfosson
Boost seems to be coming up a lot recently. Alright, time to try a grand experiment. (Good thing the project is just started, its easy to do at this point.) Yay!
Nicholas Flynt
+3  A: 

Boost.Asio

ASIO has simple web server examples.

Boost.Thread

grepsedawk
using curl would be waaay simpler.
sean riley
+1  A: 

You can try the POCO library. It has a multithreaded TCP server and a HTTPserver.

Dani van der Meer
+1  A: 

You can try my CSocksetServer class. It can handle many connections in separate threads and supplies you with lots of different events. While it doesn’t have native HTTP capabilities, I have built web servers with it.

NTDLS
A: 

You should just use cUrl with multihandles. It is better designed to do what you want than whatever it is that you have designed.

sean riley