User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 4 Jan 2004, 21:36   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
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"
Structural Integrity is offline   Reply With Quote
Unread 4 Jan 2004, 21:44   #2
SbOlly
Spelling is for pussies
 
SbOlly's Avatar
 
Join Date: Mar 2003
Location: Actually, where the feck am I........?
Posts: 446
SbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant future
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
SbOlly is offline   Reply With Quote
Unread 5 Jan 2004, 01:24   #3
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
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! :-/
JetLinus is offline   Reply With Quote
Unread 5 Jan 2004, 01:30   #4
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
Arrow 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! :-/
JetLinus is offline   Reply With Quote
Unread 5 Jan 2004, 01:40   #5
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
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! :-/
JetLinus is offline   Reply With Quote
Unread 5 Jan 2004, 02:44   #6
SbOlly
Spelling is for pussies
 
SbOlly's Avatar
 
Join Date: Mar 2003
Location: Actually, where the feck am I........?
Posts: 446
SbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant futureSbOlly has a brilliant future
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
SbOlly is offline   Reply With Quote
Unread 5 Jan 2004, 07:58   #7
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
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"
Structural Integrity is offline   Reply With Quote
Unread 5 Jan 2004, 09:44   #8
djbass
mmm.. pills
 
djbass's Avatar
 
Join Date: Apr 2000
Location: Australia
Posts: 2,152
djbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond reputedjbass has a reputation beyond repute
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.
djbass is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 13:35.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018