question about winsock UDP protocol

Posted on 2005-04-08
Last Modified: 2013-11-13
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.

Question by:yuexb
    1 Comment
    LVL 29

    Accepted Solution

    '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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    zeroMAx challenge 20 66
    count8 challlenge 13 65
    VB 6.0 printer how to align 6 34
    Change to event 1 47
    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now