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.
Re: Help with the Winsock control
You'll need to first bind the Winsock control on port 10008 like this:
vb Code:
Private Sub Form_Load()
With Winsock1
.Bind .LocalIP, 10008
End With
End Sub
Then, check the _DataArrival event to see if you are receiving any data...
vb Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData, vbString, bytesTotal
Debug.Print "Data (" & bytesTotal & " bytes): " & strData
End Sub
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.
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.
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
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.