|
4 Jan 2004, 21:36
|
#1
|
Rawr rawr
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
|
Winsock2 problem - losing packets
Right, to keep things short, what are the effects when making very quick calls to winsocks send function (TCP) ?
Because, I have this code:
netSend(OK_NAME,"");
netSend(NAME,"myname");
Netsend is a function that calls the send function.
This piece of code seems not to send the second packet. I can't tell for sure because I can't sniff the packets from localhost (see other thread), but I do know that this second packet is not received on the other side of the line.
This seems to fix my problem:
netSend(OK_NAME,"");
Sleep(200);
netSend(NAME,"myname");
Why on earth?
WSALastError doesn't give me anything so it's not me overflowing the buffer, so what could it be?
Now I'm writing this it occurs to me that perhaps the second packet is appended to the first one? Could that be? Does the socket library append packets and the receiver receives them in the same recv call? Nooo... would it?
Anyway, what are your thoughts?
__________________
"Yay"
|
|
|
4 Jan 2004, 21:44
|
#2
|
Spelling is for pussies
Join Date: Mar 2003
Location: Actually, where the feck am I........?
Posts: 446
|
Re: Winsock2 problem - losing packets
Its been a while since I've used it, but as its a streaming connection, it is possible the first and second packet are appended.
Surely you can check with the recv call to see how much data was received?
__________________
If God made me in his image, he's one fat ugly biatch.
I always get the soggy biscuit
Veni Vidi Codi
|
|
|
5 Jan 2004, 01:24
|
#3
|
Friendly geek of GD :-/
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
|
Re: Winsock2 problem - losing packets
I've made really bad experiences once implementing the IRC protocol using winsock (yes, for the damn pa scan bot, if you really wan to know). The problem was, there were, just like in any protocol, different stages and sequences, where you can only proced once you've received an answer.
For some strange reason, the messages I were sending seemed to be "split" or "merged" to chunks of data. Same with messages I wanted to receive.
I don't really know anymore, but it was damn annoying. It was actually THAT annoying, that I thought it was the servers' fault until I realized that it couldn't be coincidental if basically all servers reacted or more or less similar.
Well, anyway, I can't really remember what the problem was. And how I fixed it. If I did ^^
Isn't there some sort of winsock FlushCache() or SendCache() or ProcessQueue() or anything like it?
At least it doesn't SOUND uncommon, what you're describing...
__________________
[ »] Entropy increases! :-/
|
|
|
5 Jan 2004, 01:30
|
#4
|
Friendly geek of GD :-/
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
|
Re: Winsock2 problem - losing packets
I just found an
Code:
DoEvents
Call Sleep(5)
in the mainloop of my code as well... Coincidence? I don't think so... Well... Apparently it still didn't fix it totally.
Maybe you need to add an additional CRLF to every packet? Would be really strange, and I guess that's just IRC specific...
__________________
[ »] Entropy increases! :-/
|
|
|
5 Jan 2004, 01:40
|
#5
|
Friendly geek of GD :-/
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
|
Re: Winsock2 problem - losing packets
Oh yeah, one more question: Is this one packet really LOST? Or does it arrive later, i.e. with some of the next packets?
If it doesn't arrive at all, I didn't have the same problem...
__________________
[ »] Entropy increases! :-/
|
|
|
5 Jan 2004, 02:44
|
#6
|
Spelling is for pussies
Join Date: Mar 2003
Location: Actually, where the feck am I........?
Posts: 446
|
Re: Winsock2 problem - losing packets
In the past, I have found it useful to have my own protocol header to the front of packets I have sent. This is because depending on the nature of the connection, and the reliability, you may not get all the data you sent in one recv call, or you may receive several send calls on one recv call.
__________________
If God made me in his image, he's one fat ugly biatch.
I always get the soggy biscuit
Veni Vidi Codi
|
|
|
5 Jan 2004, 07:58
|
#7
|
Rawr rawr
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
|
Re: Winsock2 problem - losing packets
Thanks for looking into it.
I'm going back to school today, so I can test it on a real network. I wonder if the same problem occurs there too.
I checked the packetsize I received and it was the right size all the time. Atleast as far as I could check it as the recv calls are embedded deeply into the network module. So basically it seems as if the packet goes lost on sending. It better not be a silly coding error on my behalf b'cause I'm going to smack myself in the head then.
I will get a better answer today after some more tests with the network and the module.
__________________
"Yay"
|
|
|
5 Jan 2004, 09:44
|
#8
|
mmm.. pills
Join Date: Apr 2000
Location: Australia
Posts: 2,152
|
Re: Winsock2 problem - losing packets
I go on a headache inducing mission every couple of months to try and code something with sockets with more or less the simular problems. From memory you are never guarenteed that data will be sent in its entirety which is why you have to check each send call to see how many bytes were sent so you can resend the remaining data.
=[DJ Bass]=
__________________
CSS : the result of letting artists design something only an engineer should touch.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
|
All times are GMT +1. The time now is 13:35.
| |