Not able to retrive Data - Winsock UDPProtocol


Hello Gurus,

I act trying to make a Bcast System (UDP) where the server Broadcasts Data Using Timer and the client receives it, Please Check Out The Code:

' Server Codes
'---------------------
Const BROADCASTPORT = 1055
Private Sub Form_Load()
With udpBroadcast
.Protocol = sckUDPProtocol
.LocalPort = BROADCASTPORT
.RemotePort = BROADCASTPORT
.RemoteHost = "255.255.255.255"
End With
End Sub

Private Sub Timer1_Timer()
Text1.Text = "Test Bcast"
On Error GoTo ErrorHandler
Form1.udpBroadcast.SendData Text1.Text
Exit Sub

ErrorHandler:
If Err.Number <> 126 Then
MsgBox Err.Description, vbCritical, Err.Number
End If
Resume Next

End Sub
Private Sub udpBroadcast_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox Err.Description, vbCritical, Err.Source
End Sub

'Client Code
'----------------
Const BROADCASTPORT = 1055
Private Sub Form_Load()
With udpBroadcast
.Protocol = sckUDPProtocol
.LocalPort = BROADCASTPORT
.RemotePort = BROADCASTPORT
.RemoteHost = "255.255.255.255"
End With
End Sub

Private Sub udpBroadcast_DataArrival(ByVal bytesTotal As Long)
Dim IncomingData As String
udpBroadcast.GetData IncomingData
Form1.Text3.Text = IncomingData
End Sub

The Problem is - I'm not able to get the data at client end. Can you please guide me - What is wrong with this stuff.

Vivek

If you enjoyed this post, subscribe for updates (it's free)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.