question about winsock UDP protocol

hi, all, i have the following code:

Private Sub Form_Load()

    bcWinsock.Protocol = sckUDPProtocol
    bcWinsock.RemoteHost = "255.255.255.255"
    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.

xiao
yuexbAsked:
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

'''''''''''''''''''''''''''
SERVER SIDE
'''''''''''''''''''''''''''

Private Sub Form_Load()

    Winsock1.RemotePort = 2002
    Winsock1.RemoteHost = "255.255.255.255"
    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





''''''''''''''''''''''''
CLIENT / ADMIN SIDE
'''''''''''''''''''''''''


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

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

End Sub
0
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.