We have a sensor on our local network that is sending a data telegram using UDP Broadcast. How do we use Winsock to capture these messages.

The Port number that the data is being sent on is 42567.

I tried the following code

WinSockControl.Protocol = sckUDPProtocol
WinSockControl.RemotePort = 42567
WinSockControl.Bind

When stepping through this code in the IDE it accepts all these commands however it ver triggers the WinSockControl.DataArrival.

Can anyone tell me what I am doing wrong. I assumed that as the data is being broadcast around my subnet all I need to do is listen.

Thank You

Edited 3 Years Ago by Dani: Formatting fixed

sorry the above should have said it never triggers the WinSockControl.DataArrival

Please show is all the code where you ask the sock to listen for data and where you catch the arrival of said data.

For the test application on the form load I run the following code.

WinSockControl.Protocol = sckUDPProtocol
WinSockControl.RemotePort = 42567
WinSockControl.Bind

I then use the following routine to handle the incoming message. This routine never triggers.

Private Sub WinSockControl_DataArrival(ByVal bytesTotal As Long)
  Dim DataMessage As String
  WinSockControl.GetData DataMessage
End Sub

What am I doing wrong ?

Thanks for your help

JK

Edited 3 Years Ago by Dani: Formatting fixed

The problem seems to be with your server side of the app where the data gets send. If the event does not trigger on the arrival side, it means that it is not receiving anything at all, staying in a static status. What code do you have on the serverside?

We are using a commercial test application to send the message. Using CommView to monitor Port activity we can see the UDP message appearing on Port 42567 and showing the data telegram we expect. But the VB6 application doesn't seem to read it.

Mmmm. gonna have to scratch some head here. Haven't used winsock for ages. I'll search and see what I can get from my old apps or online.

Edited 3 Years Ago by AndreRet

This article has been dead for over six months. Start a new discussion instead.