"A request to send or receive data was disallowed because the socket is not connected and(when sending on a datagram socket using sendto call) no address was supplied"
here is the code
EndPoint client =
new IPEndPoint(IPAddress.Any, 0);
int bytes = udp_client.ReceiveFrom(buffer, ref client);
IPAddress address = ((IPEndPoint)udp_client.RemoteEndPoint).Address;(this is where the error is thrown
string port = ((IPEndPoint)udp_client.RemoteEndPoint).Port.ToString()
get the IP and port from EndPoint
Marie 5
Cast it to IPEndPoint and you have the Address property.
IPAddress address = ((IPEndPoint)socket.RemoteEndPoint).Address;
Nick The Newbie
"I get the EndPoint from the connected udp socket"
The socket is never really "connected" because UPD is a connectionless protocol unlike TCP.
Riceroman
Xeric Systems Ltd
EndPoint client = new IPEndPoint(IPAddress.Any, 0);
int bytes = udp_client.ReceiveFrom(buffer, ref client);string port = ((IPEndPoint)client).Port.ToString()
The reason is you cannot use RemoteEndPoint on a UDP socket.
Ron L
I keep geting this error
"A request to send or receive data was disallowed because the socket is not connected and(when sending on a datagram socket using sendto call) no address was supplied"
here is the code
EndPoint client =
new IPEndPoint(IPAddress.Any, 0); int bytes = udp_client.ReceiveFrom(buffer, ref client);IPAddress address = ((IPEndPoint)udp_client.RemoteEndPoint).Address;(this is where the error is thrown
string port = ((IPEndPoint)udp_client.RemoteEndPoint).Port.ToString()cdznr
and you will get somthing like this:
82.77.78.153:2345