Jump to content

  • Log In with Google      Sign In   
  • Create Account


winsocket overlapped i/o question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 GameCodingNinja   Members   -  Reputation: 162

Like
0Likes
Like

Posted 25 October 2012 - 07:58 AM

With the the overlapped i/o model, do you still need parse the received data because what is received can be a partial or a mixture of multiple sends?

Sponsor:

#2 clb   Members   -  Reputation: 1778

Like
0Likes
Like

Posted 25 October 2012 - 09:54 AM

Yes, overlapped io doesn't buffer up received TCP data any differently than using send()/recv() and you still need to be prepared to receive data in fragments or larger units.
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#3 GameCodingNinja   Members   -  Reputation: 162

Like
0Likes
Like

Posted 25 October 2012 - 02:04 PM

I read the overlapped io model is the most efficient but I'm not sure why. Is it because the send and receive can happen at the same time? Hence the name "overlapped"?

#4 hplus0603   Moderators   -  Reputation: 5074

Like
0Likes
Like

Posted 25 October 2012 - 03:57 PM

Overlapped I/O is most efficient because it uses the least system call overhead (and least number of overall system calls) per network stream/data unit transferred. Unless you have > 50 connections running at the same time, it's pretty hard to even measure the difference, though, and the programming model is a lot harder, so for smaller games, I highly recommend using select() in the main thread.

If you need to go overlapped, a good wrapper is boost::asio, which uses overlapped I/O with I/O completion ports on Windows, and kevent/devpoll/whatever-is-best on UNIX flavors.

Also note that the kernel will buffer both outgoing and incoming data. Your call to send() will copy the data you send into the kernel buffer, and then the kernel will take care of sending the data on the network. Your call to recv() will only receive data that is in the kernel buffer. Thus, the regular send()/recv() API also lets you "send and receive at the same time" on the actual wire, assuming your network card is full duplex.

enum Bool { True, False, FileNotFound };

#5 GameCodingNinja   Members   -  Reputation: 162

Like
0Likes
Like

Posted 25 October 2012 - 04:24 PM

Thanks for the info. From what you've said, overlapped send() is a "fire and forget". That's nice because that's one less baby sitting job that needs to be done. Don't think I'd ever need more then 50 connections.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS