Re: Error binding socket: address already in use



On Wed, Sep 13, 2006 at 04:23:35PM +0100, Alan Cox wrote:
Ar Mer, 2006-09-13 am 14:41 +0000, ysgrifennodd Peter Lezoch:
Hi,
killing a server task that is operating on a UDP socket( AF_INET,
SOCK_DGRAM, IPPROTO_UDP ), leaves the socket in an unclosed state.

For UDP the socket closes at the point the last user of the socket
closes. For TCP there is a time delay mandated by the specification.

If you are seeing UDP sockets remain open when you kill a server make
sure it hasn't forked other processes and passed them the file handle.

Additional note on REUSEADDR: The standard semantics of REUSEADDR on a
UDP socket is to allow several sockets to bind to the same address
simultaneously (!), i.e. if your server uses it you can start it several
times on the same socket, which is not what one normally wants.

Regards, Colin

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: SetSockOpt with SO_REUSEADDR parameter
    ... no concept that allows you to create multipe sockets with the same port number. ... happening is that you are throwing away the old socket and replacing it with the new ... That is not the same as creating multiple sockets with the same port #. ... Because I will send real-time video frame, I use UDP socket. ...
    (microsoft.public.vc.mfc)
  • Re: Howto find multiple servers using TCP
    ... You will have to create a UDP socket ... When a packet is sent using a UDP socket ... differences between multicast and regular udp packets, ... But if the server program is your program, ...
    (microsoft.public.vc.mfc)
  • Re: UDP source port number when using RAW socket??
    ... the source port in a UDP packet is an *optional* ... If you *do* expect UDP packets in reply to the packets you send out, ... then what you really want to do is open a plain UDP socket and bind ... Use your raw socket to send out packets and your UDP socket to receive ...
    (comp.os.linux.development.system)
  • Re: SetSockOpt with SO_REUSEADDR parameter
    ... When a client logins into server, I will create a UDP socket to send real-time video frame to it. ... This endpoint is described by the local machine's IP address and a local port number. ... When you refer to "connect" here I assume you mean that the client calls a function named Connect. ...
    (microsoft.public.vc.mfc)
  • Re: SetSockOpt with SO_REUSEADDR parameter
    ... happening is that you are throwing away the old socket and replacing it with the new ... I write a server application to send real-time video frame to client. ... Because I will send real-time video frame, I use UDP socket. ...
    (microsoft.public.vc.mfc)