|
-
Oct 23rd, 2006, 01:20 AM
#1
Thread Starter
Junior Member
WinSock
I'm using winsock to send commands over a network using this code
VB Code:
Winsock.SendData "(LD" & 1 & ")" & modConnection.DefaultAudioDrive & ":\" & rsAudio.Fields("filename").Value
Winsock.SendData "(FL" & 1 & ")" & rsAudio.Fields("id").Value
I want it to be two seperate strings, but on the server end it receives it as one.
i should look like this
(LD1)J:\123.mp3
(FL1)12
it's coming through like this
(LD1)J:\123.mp3(FL1)12
what can i do to fix this problem
-
Oct 23rd, 2006, 01:24 AM
#2
Lively Member
Re: WinSock
Well its not a problem at all.. it just sends them fast, you can do some pause between the sending procedures or just try to put DoEvents between them!
-
Oct 23rd, 2006, 01:26 AM
#3
Hyperactive Member
Re: WinSock
Winsock just sends data in a stream.. if the recieving end gets tied up with processes, the data gets run-into itself. Your best option is to send a delimiter at the end of the data, such as vbCrLf, or char(0), and then split() it into a buffer when you recieve it.
-
Oct 23rd, 2006, 01:29 AM
#4
Thread Starter
Junior Member
Re: WinSock
So when i split them, how do i set the array up so that i can tell which commands are what. none of the commands can be lost and the number of commands sent at once varies
this isn't the only time it bunches up the data. somtimes i'll get six or seven seperate commands bunched up.
c
-
Oct 23rd, 2006, 01:37 AM
#5
Lively Member
Re: WinSock
somtimes i'll get six or seven seperate commands bunched up
Try sending one
Winsock.SendData "StartData"
for the first packet before you start sending the important data strings.. and
Winsock.SendData "EndData"
after the last data is sent.
Start assembling the data strings you send from the client into a array when you get "StartData" in the winsock client and Wait for the string "EndData" to be received by winsock.. After this you have all the data you received into the array.
-
Oct 23rd, 2006, 01:41 AM
#6
Re: WinSock
You need to seperate the packets with a delimiter.
See this post:
http://www.vbforums.com/showthread.php?t=434267
-
Oct 23rd, 2006, 01:41 AM
#7
Thread Starter
Junior Member
Re: WinSock
That is an option, but it still uses the split function. how can i tell how many seperate items are in the split array?
-
Oct 23rd, 2006, 01:43 AM
#8
Lively Member
-
Oct 23rd, 2006, 02:29 AM
#9
Thread Starter
Junior Member
Re: WinSock
How about This One...
I'm getting "Script out of range when i try and do this..
VB Code:
FileID(index - 1) = Argument
I declared "Dim FileID() as String"
and index = 1.
-
Oct 23rd, 2006, 03:10 AM
#10
Lively Member
Re: WinSock
You do this when you are going to split (ex. FileID=split("test",s) )
otherwise you need to write the lenght of the array declaring it, llike "Dim FileID(10) as string"
-
Oct 23rd, 2006, 04:24 AM
#11
Re: WinSock
 Originally Posted by corydg
How about This One...
I'm getting "Script out of range when i try and do this..
VB Code:
FileID(index - 1) = Argument
I declared "Dim FileID() as String"
and index = 1.
Split() automatically creates the array based on delimeter, you don't need to assign the strings yourself, unless you intend to overwrite what was already assignd by Split()..
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
|