Hi Mike.
I might need help with this. DOnt know if im doing something wrong.
I have a server an a client that sent TCP messages to each other. but the TCP packet got lost at one moment, because of many TCP messages sent to quickly at the same time IMO.
Here is the flow.
The server was created like this:
Result = mn Start Server(0, MaxClients,0,UDPMode)
First the client makes a request for available games:
mn Add Int SendPacket,OP_GAMESEARCH
mn Add Int SendPacket,0
mn add String SendPacket,"Null",0,1
mn Send TCP 0,SendPacket,0,0,0
The server receives packets witha for loop:
` Deal with new packets from all clients
for Client = 1 to MaxClients
` Check to see if any new TCP packets have been received
TCPPackets = mn Recv TCP(0,RecvPacket,Client)
` If any have been received then do nothing
` since we don't want TCP packets from clients
if TCPPackets > 0
if is a game search, then it answers:
` If a client is searching for games
if Operation = OP_GAMESEARCH
for RPAvaibleGames = 0 to array count(RPgamesCreated(0))
` Tell clients that a new client has joined
mn Add Int SendPacket, OP_AVAIBLEGAMES
mn add String SendPacket,RPgamesCreated(RPAvaibleGames).gameCreationStr,0,1
mn Send TCP 0,SendPacket,Client,0,1
rem mn Send TCP All 0,SendPacket,0,0,Joined
next RPAvaibleGames
endif
The games are received in the client, and filled Ok.:
` Check for new TCP messages
TCPPackets = mn Recv TCP(0,RecvPacket,NULL)
` If there is a new TCP message
if TCPPackets > 0
Operation = mn Get Int(RecvPacket)
MGameStr$ = mn Get String(RecvPacket,0,1)
rem message MGameStr$
if Operation = OP_AVAIBLEGAMES
WHen, the games are available the user (the client) chooses a game,and Joins requesting host data.:
mn Add Int SendPacket,OP_GAMEJOIN
rem message str$(hostGameSelection)
mn Add Int SendPacket,joinGameSelection
mn add String SendPacket,joinedGameName$,0,1
mn Send TCP 0,SendPacket,0,0,1
joinedState = 1
rem wait 200
rem message "entro -1"
Tehe server returns host data:
` If a client created a game
if Operation = OP_GAMEJOIN
for RPAvaibleGames = 0 to array count(RPgamesCreated(0))
if MGameStr$ = RPgamesCreated(RPAvaibleGames).gameCreationStr
index = RPgamesCreated(MGameID).player1ID
mn Add Int SendPacket, OP_GAMEHOSTDATA
mn add String SendPacket,gameClients(index).TCPIP,0,1
mn Send TCP 0,SendPacket,Client,0,1
message "server - 1"
exit
endif
next RPAvaibleGames
endif
In this part of the code packets are not received. It does not receives the packets of new host data:
` Check for new TCP messages
TCPPackets = mn Recv TCP(0,RecvPacket,NULL)
` If there is a new TCP message
if TCPPackets > 0
Operation = mn Get Int(RecvPacket)
ConnectIP2$ = mn Get String(RecvPacket,0,1)
message "Packets received"
if Operation = OP_GAMEHOSTDATA
If I put a delay after OP_GAMEJOIN packet is sent (where the client request host data ), for example:
The Packet is received succesfully.
This can be due to send and receive thought the same IP and POrt TCP packets so fast? (I dont know, and Im a bit confused).
Cheers.
AlfaX.