views:

39

answers:

2

What is the purpose of using ReuseSocket to true. I dont know what it do if i set this property to true. What happens if i set ReuseSocket to true or flase. I am trying to create a socket but it is giving me error again nd again.

Error

A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied: Stack:    at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.Socket.Send(Byte[] buffer)
   at Serverdll.ServerApp.StopReceiveServer() : Function Name : Int32 Send(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)


Description :Address Already In Use., Error Code: 10048, Message On Start: Only one usage of each socket address (protocol/network address/port) is normally permitted
+1  A: 

Normally only one socket for a particular protocol is allowed to be bound to a given address at once. So you can have only one UDP socket bound to a particular IP address and port.

If you need to have multiple sockets bound to the same combination of protocol/ip address/port then you should set the ReuseAddress socket option to true on Socket you create before you call Bind() (or any method which implicitly binds the Socket).

Otherwise, you should ensure that the one socket is closed using one of the Close() methods before creating another.

Nick Smith
A: 

When the connection is closed there is still a long waiting period as defined by the TCP specifications. This option allows you to minimize the waiting time for closing a connection

Jay