question about winsock UDP protocol

hi, all, i have the following code:

Private Sub Form_Load()

    bcWinsock.Protocol = sckUDPProtocol
    bcWinsock.RemoteHost = ""
    bcWinsock.RemotePort = 1111
    bcWinsock.LocalPort = 1007
    bcWinsock.Bind 1007
End Sub

Private Sub bcWinsock_DataArrival(ByVal bytesTotal As Long)
    Dim helloInfo As String
    Dim serverInfo As String
    bcWinsock.GetData helloInfo

    statusText.Text = statusText.Text + helloInfo
    severInfo = "info from server"
    bcWinsock.SendData serverInfo
End Sub

the following run time error happened when executing "bcWinsock.SendData serverInfo" :

Run-time error '10065':
No route to host .

does anyone know what's going on?  thanks in advance.

Who is Participating?
nffvrxqgrcfqvvcConnect With a Mentor Commented:
'UDP packets don't go past the routher..from what I know if your connecting within your LAN then udp protocal will work, if you are trying to connect outside it won't work.

from what I see you are trying to broadcast the udp server..

'This is how I do it using UDP


Private Sub Form_Load()

    Winsock1.RemotePort = 2002
    Winsock1.RemoteHost = ""
    Winsock1.Bind 2001

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sTr As String
Winsock1.GetData sTr
MsgBox sTr, vbInformation, "UDP Broadcasting"

End Sub


Private Sub Command1_Click()
Dim sTr As String
sTr = "Broadcast using UDP"
Winsock1.SendData sTr
End Sub

Private Sub Form_Load()
With Winsock1
        .RemoteHost = ""   ' Broadcast IP
        .RemotePort = 2001         ' Port to connect to.
        .Bind 2002                       ' Bind to the local port.
    End With

End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.