G
Guest
Hi,
I'm using multicast using C#. When receiver disconnects from the server and
reconnects, following exception is occuring
System.Net.Sockets.SocketException: Only one usage of each socket address
(protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.Bind(EndPoint localEP).
I guess, this exception is occuring because, I'm trying to bind the multicast-
socket with local IP again and again, whenever I'm reconnecting.
How can we unbind the socket with IP. How can receiver stop and start
receiving multicast messages from the multicast server.
When I tried to close the socket, I'm getting "ObjectDisposed" exception,
that is, as I'm using BeginReceive and EndReceive for receiving multicast
messages, the exception is occuring at "socket.EndReceive".
Receive()
{
mcastClientSocket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram,
ProtocolType.Udp);
IAsyncResult ares =
mcastClientSocket.BeginReceiveFrom(this.messageBuffer,0,this.messageBuffer.Length,SocketFlags.None,ref remoteEP,
new AsyncCallback(this.OnMcastMessageArriaved),this.mcastClientSocket);
}
OnMcastMessageArriaved()
{
Socket s = (Socket)aRes.AsyncState;
int bytesReceived = s.EndReceiveFrom(aRes,ref remoteEP);
}
How can we avoid executing "OnMcastMessageArriaved" method when
the corresponding Socket is closed.
Kindly let me know.
Cheers,
Naveen.
I'm using multicast using C#. When receiver disconnects from the server and
reconnects, following exception is occuring
System.Net.Sockets.SocketException: Only one usage of each socket address
(protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.Bind(EndPoint localEP).
I guess, this exception is occuring because, I'm trying to bind the multicast-
socket with local IP again and again, whenever I'm reconnecting.
How can we unbind the socket with IP. How can receiver stop and start
receiving multicast messages from the multicast server.
When I tried to close the socket, I'm getting "ObjectDisposed" exception,
that is, as I'm using BeginReceive and EndReceive for receiving multicast
messages, the exception is occuring at "socket.EndReceive".
Receive()
{
mcastClientSocket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram,
ProtocolType.Udp);
IAsyncResult ares =
mcastClientSocket.BeginReceiveFrom(this.messageBuffer,0,this.messageBuffer.Length,SocketFlags.None,ref remoteEP,
new AsyncCallback(this.OnMcastMessageArriaved),this.mcastClientSocket);
}
OnMcastMessageArriaved()
{
Socket s = (Socket)aRes.AsyncState;
int bytesReceived = s.EndReceiveFrom(aRes,ref remoteEP);
}
How can we avoid executing "OnMcastMessageArriaved" method when
the corresponding Socket is closed.
Kindly let me know.
Cheers,
Naveen.