Ok, this is kind of a multipart question...
1) Let's say I limit my connected users to 5 - I have code to send a reject on connections unless there are less then 5 users connected to my program.
Now, let's say I have 100's of people hitting the connection request to the server, efectively so I keep receiving messages FD_ACCEPT messages - what can I do to guarantee my main server loop will get run if I keep getting bombarded with FD_ACCEPTS?
2) Now I know there are times where all the data for a complete packet may not be received (or sent from what I have read)
So, what do I need to do to make a packet work?
Let's say my packet structure is:
char Type (there would be <256 packet types)
int PacketSize
union of multiple sub types...
type 1
char MsgFrm[20]
char Msg[100]
BOOL Private
Type 2
short CommandID
char CommandParameters[50]
Type 4
char LargeMOTD[500]
etc.
Ok, so what kind of a recv function do I need to create to make sure I get the entire packet? I would prefer to use pointers, but as that may make it EXTREMELY difficult, I could use char arrays for my text messages, command parameters and motd messages, etc..
3) Right now, the client and server are both Windows based. Let's say I moved one or the other to an alternative OS in which I might have to do some data conversion. I'm not sure how I do this. Do I have to make my packets arrays of int or shorts and do a conversion on everything? How do I do this??
Pls, any help would be appreciated. I'm REALLY lost on this part of async winsock programming. I have my message loop setup, but until I understand/have a proper recv and send to make sure all data is sent/arrives, I really don't know what to do.
Basically, I'm lost in this area of network programming. I have most of what I need to do figured out, but I am just having trouble with these last few areas.
PLEASE do not show MFC, I am doing this using the Win32API and Winsock
Please do not reference MSDN and say just read here, I already have. I have also read a variety of articles including the Winsock FAQ as well as the winsock documents at Gamedev.net (some decent network programming docs).
I need some viable code that I can look at, step thru and understand how it works.