Network game problem.

Started by
9 comments, last by laeuchli 22 years, 3 months ago
if(amount2==SOCKET_ERROR)
{

}
else
{
amount+=amount2;
}
}while(amount }
return amount;
}


argh u seem to have missde somthing here
does it say while(amount {is smaller then}nBufLen) this forum doesnt like certian characters it seems

coz if it does
then theres a problem
unless ure sending exactly 100 bytes of actual data in every packet
which i doubt
but if u are then i have no idea

anyways if u are sending something like 10 bytes for every packet
then that means ure server will first recieve 10 of those packets before it finishes the function

u shouldnt do that
just simply do a recv call and process the data u got
now as this is tcp/ip i dunno how to handle incomplete messages as tahts what happens
if u read one of the other threads ull c there
that u may send 10 packets but may only need to do one recv call or vice versa etc
but i did do a little bit of tcp but over a lan so that was not a problem
u can pretty much skip that for now
anyways
this should fix ure problem
however i dunno how this works line works
while(1==1);
not that c++ proficient

int CIOSocket::Receive(void* lpBuf, int nBufLen, int nFlags, bool bAcceptPartial)
{
int amount=0;
if(bAcceptPartial==true)
{
amount=recv(Socket,(char *)lpBuf,nBufLen,nFlags);
}
else
{
int amount2=recv(Socket,(char *)lpBuf,nBufLen,nFlags);
if(amount2==SOCKET_ERROR)
{

}


return amount;
}


and if ure really stumped then message here and leave ure email and ill send u a copy of an old pong game i made
very simple but the code is awful but its got a simple client/server thing
tho im not sure if i still have it
might have been a chat thing
dunno but ill c if i can find it if u need it

Hope this helps =)

Edited by - Do00d on January 6, 2002 8:47:10 AM

This topic is closed to new replies.

Advertisement