|
-
Feb 1st, 2000, 09:32 PM
#1
Thread Starter
Addicted Member
Hi
I'm having some trouble sending data with winsock.
My client application will send data to my server application.
I user TCPconnect.SendData ("abc...") etc.
I use a sub proecdure to find out what the client has send. All messages are prefixed with a 5 character code.
Then the server will do something according to what it recieved.
The problem I get is that sometimes the client needs to send 2 bits of data.
i.e.
TCPconnect.SendData ("blah blah")
TCPconnect.SendData ("blah2 blah2")
But the server will recieve "blah blahblah2 blah2"
Is there anyway to make sure that the data has been sent before it sends the next string?
I've tried putting DoEvents inbetween the two SendData commands, but that doesn't work.
-
Feb 2nd, 2000, 05:02 PM
#2
Thread Starter
Addicted Member
Guys...
This is getting realy urgent!
-
Feb 2nd, 2000, 05:07 PM
#3
New Member
Reset the connection in between your sends.
It's a good idea when using winsock to close your connection when it is not needed.
-
Feb 2nd, 2000, 08:58 PM
#4
Fanatic Member
A couple of strategies I use are to add a control character to the end like vbcrlf and have the server look for it when data comes in, or have the first character be a count character to say how much text is comming.
eg if less than 256 characters then
Sendtxt = "The string I want to send"
TCP.Senddata CHR(Len(Sendtxt)) & Sendtext
Then at the server use asc(left(data,1)) to get the number of arrived characters.
Remember the reason that these are necessary is that you are using packets and buffers and winsock might send data when a buffer is full (before you're ready) or hold the data a little till more comes. Both the above work best together, the VbCrLf to copy arrived data out of the buffer at the time of the message end and the chr() count to process it.
It helps to have a few send/recieve processing functions prepared for a text->winsock app
-
Feb 2nd, 2000, 09:04 PM
#5
Thread Starter
Addicted Member
Thanks guys!
You've just saved my life, (ish).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|