|
-
Jun 3rd, 2001, 09:47 AM
#1
Thread Starter
Member
Problem with Winsock Control
I am trying to develop an online application using VB 6.0, and i use the winsock control to handle communication of my application. Sorry i have to write this much, i can't explain it shortly to justify my problems due to language barrier.
When i invoke the winsock.senddata method once, i am able to send the data i want, however, when i invoke the winsock.senddata twice in a procedure(or a loop), the message that is sent becomes the sum of two senddata, looks like this:
winsock1.senddata "ABC"
'somewhere else in the procedure later...
winsock1.senddata "DEF"
'at the client side
winsockclient.getdata msg
'msg becomes "ABCDEF"
I manage to solve problem like this, by putting a Doevent between the first and second senddata. However, i encountered the same problem again when....
winsock1.senddata "ABC"
Doevents
Winsock1.senddata "DEF"
Doevents
for i = 1 to 5
winsock1(i).senddata "GHI"
doevents
next i
On the client side, the first message "ABC" is received , but the second and third message gets jumbled up again, even when i put Doevents before the loop, sometimes it doesn't sometimes it does, i think the only explanation is when senddata is invoked, the control turn into "Sending" status, putting doevents will allow other procedure to be processed first before going to the next statement, therefore will solve my problem temporarily.
However (again), my app is meant for internet usage, sometimes a lag will force my control to be in "sending" status longer.
I thought about the problem and i think the only solution is to make a buffer for the senddata method, using arrays, meaning that i will output the data to an array whenever i want to senddata, and send the data on the first index of the array with a timer constantly checking if there's anything in the array to send.
Problems with my solution: Have to make a loop to move the data in second array to the first, the third to second, when data is being sent, not feasible when i have multiple winsock control running and will cause a major lag when there are too much data to be sent.
Please let me know if you know a solution to my problem, thank you.
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
|