#107541 - ProblemBaby - Mon Oct 30, 2006 6:52 pm
can someone tell me how I can do my wifi code stable?
it works, sometimes 10seconds, sometimes about a minute (its so annoying that it take so much time to test so it would be awesome if you could point out something that would make it stable)
here is the code:
// for player 0
for player x:
the IP's is hardcoded now because iam testing.. but the idea is to sent to player 0, when player 0 have recieved from all other players it makes up a list and send to all the other players.
some questions.. is sendto stable? would it be a good idea to check that correct amount data have been sent?
Is the problem that sometime sendto send to little data, and recv got hooked?
should it look something like this maybe?
u8 *bufSize;
while (bufSize)
{
if ((t = sendto(buf, bufSize...)) > 0)
{
bufSize-= t;
buf += t;
}
}
u8 *bufSize;
while (bufSize)
{
if ((t = recvfrom(buf, bufSize...)) > 0)
{
bufSize -= t;
buf += t;
}
}
would something like this be stable???
one more question.. is it possible to send to all IPs?
(I want it when searching for players)
thanks!
it works, sometimes 10seconds, sometimes about a minute (its so annoying that it take so much time to test so it would be awesome if you could point out something that would make it stable)
here is the code:
// for player 0
Code: |
while (recvfrom(Socket, pRecieveData, Size, 0, (struct sockaddr *)&sain_, &i) != (int)Size); CopyMemory((u8 *)pRecieveData+Size, pRecieveData, Size); CopyMemory(pRecieveData, pSendData, Size); sain.sin_addr.s_addr = 0x0302A8C0; sendto(Socket, pRecieveData, Size*4, 0, (struct sockaddr *)&sain, sizeof(sain)); |
for player x:
Code: |
sain.sin_addr.s_addr = 0x0202A8C0; sendto(Socket, pSendData, Size, 0, (struct sockaddr *)&sain, sizeof(sain)); while (recvfrom(Socket, pRecieveData, Size*4, 0, (struct sockaddr *)&sain_, &i) != (int)Size*4); |
the IP's is hardcoded now because iam testing.. but the idea is to sent to player 0, when player 0 have recieved from all other players it makes up a list and send to all the other players.
some questions.. is sendto stable? would it be a good idea to check that correct amount data have been sent?
Is the problem that sometime sendto send to little data, and recv got hooked?
should it look something like this maybe?
u8 *bufSize;
while (bufSize)
{
if ((t = sendto(buf, bufSize...)) > 0)
{
bufSize-= t;
buf += t;
}
}
u8 *bufSize;
while (bufSize)
{
if ((t = recvfrom(buf, bufSize...)) > 0)
{
bufSize -= t;
buf += t;
}
}
would something like this be stable???
one more question.. is it possible to send to all IPs?
(I want it when searching for players)
thanks!