   Multiplayer Programming
  HI, I am new to multiplayer game programming. I want to understand the basic fundamentals related to multiplayer programming.Can anyone suggest some books, tutorials, materials etc from where I can get knowledge related to it.I want to know what are the issues concerning the multiplayer like->Issues in terms of software and hardware->To learn network programming, is it to start from socket programming->What aspects of optimisation should be taken care of..etcAll suggstions are welcome   
  Please read the forum FAQ.  It contains the exact lists you have asked for.   ;  If you are a beginner in game programming and have a little knowledge of c# then it is better to network-program in xna.It is quite easy just like two lines of code and you have no errors.Wanna learn something DirectPlay in C#.Net is also quite easy.Xna tutorials are available at 01FES and DirectPlay will be very soon.You check out tutorials at :http://www.01fes.com/   ;  At the risk of giving hplus0603 the shits  . You could try the tutorials here:Winsock tutorials;At the risk of giving hplus0603 the shits  . You could try the tutorials here:Winsock tutorialsWinsock Tutorial 1// Display message from serverchar buffer[1000];memset(buffer,0,999);int inDataLength=recv(Socket,buffer,1000,0);std::cout<<buffer;[/quote]Yea, you better be really careful reading through those. I see a lot of problems in all examples that can lead you down the path of network programming ruin. If you wanted to follow a tutorial like that, you have to consult MSDN for every API function used to see how to correctly use it. 99% of the time, those simple tutorials misuse them and if you blidnly follow them, your programs will be incorrect. They may still work, but they will nonetheless still be incorrect.;  I fail to see have this is 'wrong' any way. The tutorials show, with great explanation, what is happening. Also all having reference to MSDN at the bottom of the page.If you want to see examples of fully fledged servers with full error checking and server/client security, you might want to ask Blizzard if they can supply you with the source code for Battle.net or something. ;// Display message from serverchar buffer[1000];memset(buffer,0,999);int inDataLength=recv(Socket,buffer,1000,0);std::cout<<buffer;I agree. That code is pretty terrible! It looks like a typical example of someone thinking "I'm trying to learn this network programming thing, so I'll write a tutorial about how to do it!" and then putting at least four beginner-level mistakes in it.First, you don't need to clear the buffer before you recv() into it, because recv() will overwrite it and doesn't care what's in it.Second, you need to make sure you manually zero terminate the string, because recv() may not actually return a zero-terminated string. As it is, a string of 999 or of 1000 bytes will not be zero terminated (because only the first 999 bytes are cleared, so the last byte is non-0, and that last byte may or may not be overwritten by the call to recv()).Third, it needs to test inDataLength for a return value of less than 1, which generally means some error condition. ("stream closed" on 0, if it's TCP, and "error" on -1)Fourth, if this is using TCP, which is likely because it's recv() instead of recvfrom(), then that code will totally lose all bytes after an embedded 0, which may be all or part of whatever the next message was that the other end sent.   ;  You don't need to manually terminate with zero because memset has done this allready  . Agreed, the 999 should be 1000.With the error checking. There is a whole tutorial on that, if you read deep enough. It even states on the the following;Previously we purposely omitted too much detail in error handling so as not to overwhelm newcomers. Now we examine error handling in greater detail. When we are finished, we should be able to troubleshoot our applications so we can pinpoint where a problem may exist with greater efficiency.[/quote]So, the mistakes in the code total 1 (not 4). And this mistake is far from critical.Tutorials are there to give an insight on how to do something. Not a fully fledged solution. It is upto the coder what they do with the 'insight'.How many examples on MSDN use full error checking?They provide information how you can use a function and advise on how errors are handled. This is exactly what win32developer.com does.;So, the mistakes in the code total 1 (not 4). And this mistake is far from critical.I see more errors than that, and many of them are critical.  They are quite likely to happen, even in a short demo or tutorial.Remember that TCP is a stream protocol.  You may not retrieve the entire string (assuming you are sending a string).  You also may retrieve more than a single string.  You absolutely must account for this.You have no guarantee that you will receive your entire string.  You also have no guarantee that you won't receive more than your string.1. Failure to handle a complete object is a critical failure that will leave your system in an invalid state. 2. Failure to handle more than one full object is a critical failure that will leave your system in an invalid state.3. Failure to properly handle string termination is a critical failure that will likely crash your program.These are very likely to happen to anybody using your tutorial, so you need to be prepared to deal with them.4. Failure to detect a transfer error is a failure, although slightly less critical for a tutorial.5. Misuse and misunderstanding of how memory works is a performance error.  You need to set at most one byte, more likely you need to set zero bytes.  6. Improper use of magic numbers is a style error, and would have prevented one of your bugs.Looking over those specific tutorials, they are all riddled with bugs.  It certainly seems to me like it is a tutorial written by a beginner.   ;You don't need to manually terminate with zero because memset has done this allready  .In my opinion, when you're in a hole, you should stop digging. You just right now showed that not only do you not understand insecure code, you don't even understand a problem when pointed out to you.If the buffer is 1000 bytes long, and I send a packet of 1000 non-zero bytes, then the buffer will not be zero terminated, no matter what you put into the buffer before it gets overwritten by the data I send to it.Really. Network programming is super hard. The human brain isn't REALLY made to understand it at all, because it's not like any process that normally occurs "on the Savannah." I make mistakes often enough, which is why I try to get code reviews for any code I write, and I fix problems that people point out. You should not take feedback on bad code and just ignore it, or worse, disregard it.   