View Single Post
Old 09-18-2010, 12:55 PM   #6
Kylotan
Member
 
Join Date: Jun 2003
Location: Nottingham, UK
Home MUD: Abattoir (Smaug)
Home MUD: ex-Jellybean (Smaug)
Home MUD: ex-Dark Chambers (Merc)
Posts: 174
Kylotan is on a distinguished road
Send a message via ICQ to Kylotan Send a message via AIM to Kylotan Send a message via MSN to Kylotan Send a message via Yahoo to Kylotan
Re: New to network programming a couple questions:

No. The operating system will only tell you there is data once it's arrived, no matter how long it took to get there. You just have to copy it over, which takes the same amount of time whether they're on your local LAN or a 1200bps modem from 1983.

Most muds use the select() function to be told which sockets have data waiting, and have a local buffer for each socket. When the data is ready on a socket, read it and add it to the end of the buffer. If the buffer contains enough data to read a command out of it, read it and process it, taking the data out of the buffer. Repeat for as many commands as you can read, and for as many sockets have got new data.
Kylotan is offline   Reply With Quote