Re: Question about UdpClient?

From: Philip Rieck (junk_at_mckraken.com)
Date: 10/06/04


Date: Wed, 6 Oct 2004 07:02:34 -0500

Your RemoteIpEndPoint (with IPAddress.Any, port 0) is used only as a byref
parameter - that is, it is filled in with the actual IPAddress and port that
the data came from. So you're not listening on port 0. That's just a value
you're passing to a constructor because UdpClient.Receive takes a
constructed IPEndPoint - it's not actually used. If you want to limit the
host that you can accept UDP traffic from, specify that in the Connect
method (which you seem to havedone)

"Emilio" <[void]> wrote in message
news:ufEW764qEHA.3760@TK2MSFTNGP09.phx.gbl...
> Question about UdpClient sample
>
> ' This constructor arbitrarily assigns the local port number.
> Dim udpClient As New UdpClient()
> Try
> udpClient.Connect("www.contoso.com", 11000)
>
> ' Sends a message to the host to which you have connected.
> Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody there?")
>
> udpClient.Send(sendBytes, sendBytes.Length)
>
> ' Sends message to a different host using optional hostname and port
> parameters.
> Dim udpClientB As New UdpClient()
> udpClientB.Send(sendBytes, sendBytes.Length, "AlternateHostMachineName",
> 11000)
>
> 'Blocks until a message returns on this socket from a remote host.
> Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
>
> ' Blocks until a message returns on this socket from a remote host.
> Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
> Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
>
>
> I was wondering what is the reason that when we need to receive
> a message from a remote host we do IPAddress.Any,0
> i.e why do we wait at port 0 rather than 11000, which is where
> we sent to?
>



Relevant Pages

  • SCP via SSH tunnel works, then not, then works again
    ... I am using SSH to perform local port forwarding from my local machine ... to a remote machine behind a firewall at a remote site ... back to remote host RA, ...
    (comp.security.ssh)
  • RE: basic port forwarding help
    ... So this will forward port 1204 on your local system to port 1204 ... > from the remote host to the client so my assumption ... from), our remote host, and the target host ... target system to reply to the remote system. ...
    (SSH)
  • Re: Port TCP used by Exceed
    ... You may be using an XDMCP query from eXceed to the remote host. ... All X traffic from the remote host to the X server will connect on port ... So, i suppose that in all case, i can disable telnet without any problem. ...
    (comp.unix.solaris)
  • Re: Unable to Connect to Server/Client Desktop using RWW
    ... Port 4125 only needs to be forwarded to the external NIC IP address on your ... SBS server. ... When a remote user cannot connect, asre there any errors listed in the event ... logs of the SBS server or of the target LAN workstation? ...
    (microsoft.public.backoffice.smallbiz)
  • Re: Remote Desktop
    ... I've gone to http://www.canyouseeme.org on the remote computer and it can ... Not sure if the modem is actually a router. ... As for port forwarding in my router, I've typed in 3389 for the ... Al Jarvi (MS-MVP Windows Networking) ...
    (microsoft.public.windowsxp.network_web)

Loading