Hi Brassawiking,
I'm no expert at game related network coms, but I think one of the key things is to keep the amount of data you send small (less than 1024 bytes) so that it fits into one packet.
Rather than send each item seperately, which may result in lots of packets, you could pack the data into a string.
Code:
function wordToString(data:word):string;
begin
result:=chr(data div 256)+chr(data mod 256);
end;
function stringToWord(srcData:string;startPos:integer):word;
begin
if (length(srcData)<startPos+1) then
result:=0
else
result:=ord(srcData[startPos])*256+ord(srcData[startPos+1]);
end;
You can encode other values such as integer (although integer is trickier because of sign) in a similar manner. Then you can piece together a packet as a single string...
Code:
packet:=wordToString(playerX)+wordToString(playerY);
At the other end, assuming this is the only data you send...
Code:
playerX:=stringToWord(packetData,1);
playerY:=stringToWord(packetData,3);
In doing this, you can send a single string. This will reduce the number of packets you send.
I can't help further because as I say, I'm no expert. One place you could look is the Tutorials section.
Bookmarks