Results 1 to 4 of 4

Thread: Winsock Send/Recieve non-text data [RESOLVED]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    16

    Angry Winsock Send/Recieve non-text data [RESOLVED]

    Down Down
    Last edited by Xelen; Dec 14th, 2003 at 10:00 PM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    16

    update on probem...

    Read Below for new problem
    Last edited by Xelen; Dec 14th, 2003 at 02:57 PM.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    16

    Narrowed it down

    ok I've narrowed my problem down to where I want send either a Collection or PropertyBag, or a combo of both with Winsock. Right now I am a bit confused as to how to do that. I will provide some sample code, so as so you can see what I am trying to do and what is incorrect because mycode doesn't work.

    Client Program

    Code:
     
    
    Private Sub Command1_Click()
    
    'should send a collection returned by my function ListDir.
    'I know it returns collection proprely,  tested that before
    'attempting to use winsock
    
    Winsock.SendData ListDir("C:\")
    
    End Sub

    Server Program

    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    
    'MsgBox is debug line, it never gets fired when I use button in
    'my client program to send the Collection, any idea why?
    
    MsgBox "Recieved"
    
    'vars to deal with the collection I "should" recieve
    Dim Blah As New Collection, Block As Variant
    
    Set Blah = Winsock1.GetData(Blah)
    
    For Each Block In Blah
    'for every directory in Collection add it to a textbox
    txtHistory = txtHistory & Blah & vbCrLf
    Next Block
    End Sub
    So basically my problem is that I am trying to send a collection to my server but it is maybe not reaching it somehow. But I know for a fact that my programs are connected. I made sure that it would fire a MsgBox when it closes connection. It fires properly.

    edit
    -------
    Ok I have discovered for some reason it is not sending at all as far as I can tell, I added this code to my client program for debugging purposes. And I bet you can guess what didn't hapen based upon my code...

    Code:
    Private Sub Winsock_SendComplete()
    MsgBox "SENT"
    End Sub
    Last edited by Xelen; Dec 14th, 2003 at 03:09 PM.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    16

    RESOLVEMENT

    WOOHOO, OH YEAH I FINALLY FOUND A WAY!

    Problem was Winsock didn't reconize Collection data type so refused to send, so what I did was modified my DirList function to return a PropertyBag and then turned it into a byte array before sending it.

    Here is a link of a good thread that shows a few example codes that you can use to achieve exactly that.

    http://vbforums.com/showthread.php?s=&threadid=242564

    Thank you to everyone who was in that thread I linked, that was a good example I needed to figure out my problem. Took forever to dig it up too.

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