Error 10048 in bind()


  • Hello,
      My application a simple MDI application.Take data in serial port and send it to another computer using tcp/ip .
    In the first iterartion every thing is fine.Both server and client systems works well.
    Then if the server is turned of off(disconnect using socket.close() method) and then client is also closed .
    without closing the application if i start open the socket and execute socket.bind() method , the exception 10048

    thanks in advance.

    Wednesday, September 5, 2007 8:12 AM

All replies

  • It means that yProxy is unable to bind to the Local (Proxy) Port that you have configured. That port is probably already in use.

    Wednesday, September 5, 2007 11:54 AM
  • Hello,
     Thnks for u  r reply.but as i hv stated the same application was using that ip and port and are closed using close() method.And then when try to open the same ip and port which was closed then i m getting the above error.

    Thursday, September 6, 2007 6:27 AM
  • The problem is that binding and unbinding to endpoints is a costly operation for the Operating System.. And it takes a while before it is performed... If you want to speed up this process you'll have to find a way to pass in the option SO_REUSEADDR (i can't remember the .net equivalent right now) to notify the OS that the resource has to be cleaned up faster (and thus make it available faster)...

    serverSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, true);

    (Another interesting setting could be HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpTimedWaitDelay)

    Thursday, September 6, 2007 7:15 AM
  • thnks a lot
     But i didnt get that interesting setting " HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpTimedWaitDelay)"

    Thursday, September 6, 2007 8:09 AM
  • You can read about the setting in http://technet2.microsoft.com/windowsserver/en/library/38b8bf76-b7d3-473c-84e8-e657c0c619d11033.mspx?mfr=true .. As the page says: Windows Server 2003 does not add this entry to the registry. You can add it by using the registry editor Regedit.exe. (Explaining why you couldn't find it Wink)

    Thursday, September 6, 2007 10:50 AM
  • Basically a TCP connection is unique with the combination of (client ip, client socket, server ip, server socket).

    I can think of two issues in this case

      1. the previous connection with this combination is still alive in the system.(do a netstat -a). Most probably it will be in TIME_WAIT state.

      2. and you are again trying to make use of same combination in next request. 

    Thats the reason it gives that error.

    May be you can use SO_REUSEADDR or SO_EXCLUSIVEADDRUSE while trying to connect again.


    Tuesday, July 24, 2012 1:05 PM