Results 1 to 6 of 6

Thread: Help with the Winsock control

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    7

    Help with the Winsock control

    I have a device that broadcasts UDP multicast messages. The device has a linux based OS and a hard-coded IP address of 192.168.0.40 and according to the documentation it sends out multicast messages on 255.255.0.1 (port 10008). I have seen the messages using wireshark (ver 1.0.0). I need to write an app in VB6 (I don't have vb.net) to receive these messages but I am having trouble. I have tried using the winsock control and setting the protocol to UDP but I'm not receiving anything (or I'm doing it incorrectly). I think I may need to make some windows api calls in order to "join" a multicast group, but I'm not sure. I don't think the wireshark program is "joining" anything, it's just displaying what's on the cat5. Can anyone please make a suggestion or show an example? Thanks.

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

    Re: Help with the Winsock control

    You'll need to first bind the Winsock control on port 10008 like this:

    vb Code:
    1. Private Sub Form_Load()
    2.     With Winsock1
    3.         .Bind .LocalIP, 10008
    4.     End With
    5. End Sub

    Then, check the _DataArrival event to see if you are receiving any data...

    vb Code:
    1. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    2.     Dim strData As String
    3.    
    4.     Winsock1.GetData strData, vbString, bytesTotal
    5.     Debug.Print "Data (" & bytesTotal & " bytes): " & strData
    6. End Sub

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Help with the Winsock control

    There is no support for multicast groups in the standard Winsock control. API calls might be used to accomplish this, but in general I think you'd want to look at commercial 3rd party controls.

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

    Re: Help with the Winsock control

    Hm I wasn't really sure what a multicast was...I figured if the device can send data to an IP/port then the VB program should be able to see it. Unless MultiCast is a completely different protocol other than TCP/UDP.

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

    Re: Help with the Winsock control

    Here is a multicast example in VB6 with the Winsock control. I haven't looked at its code, though:

    http://www.pscode.com/vb/scripts/Sho...29005&lngWId=1

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Help with the Winsock control

    Wow, nice find. Glad to see it doesn't take too much to make it work.

    The Winsock control overwrites so many manually set sockopts I wasn't sure it was practical.

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