Results 1 to 11 of 11

Thread: WinSock

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Location
    Bentonville, AR
    Posts
    22

    WinSock

    I'm using winsock to send commands over a network using this code

    VB Code:
    1. Winsock.SendData "(LD" & 1 & ")" & modConnection.DefaultAudioDrive & ":\" & rsAudio.Fields("filename").Value
    2.        
    3.         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

  2. #2
    Lively Member
    Join Date
    Oct 2006
    Posts
    81

    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!

  3. #3
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Location
    Bentonville, AR
    Posts
    22

    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

  5. #5
    Lively Member putta's Avatar
    Join Date
    Oct 2004
    Location
    Original Citizen Of This Planet
    Posts
    86

    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.

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: WinSock

    You need to seperate the packets with a delimiter.

    See this post:
    http://www.vbforums.com/showthread.php?t=434267

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Location
    Bentonville, AR
    Posts
    22

    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?

  8. #8
    Lively Member
    Join Date
    Oct 2006
    Posts
    81

    Re: WinSock

    You mean Ubound(array) ?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Location
    Bentonville, AR
    Posts
    22

    Re: WinSock

    How about This One...

    I'm getting "Script out of range when i try and do this..
    VB Code:
    1. FileID(index - 1) = Argument

    I declared "Dim FileID() as String"
    and index = 1.

  10. #10
    Lively Member
    Join Date
    Oct 2006
    Posts
    81

    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"

  11. #11
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: WinSock

    Quote Originally Posted by corydg
    How about This One...

    I'm getting "Script out of range when i try and do this..
    VB Code:
    1. 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
  •  



Click Here to Expand Forum to Full Width