On Mon, Dec 25, 2000 at 11:42:04PM +0530, Saibal kumar Adhya wrote: > > Hi, > Can anyone tell when sock structure (include/net/sock.h) is freed > after application calls shutdown, close system call or tcp gets a > 'reset'? Thank in advance. This code is from 2.4.0-test13-pre4. See, for example, the call to sock_put() (which calls sk_free()) at the bottom of net/ipv4/tcp.c:tcp_close(). tcp_close() takes a struct sock as an argument and, when all is said and done, it frees it. bh_unlock_sock(sk); local_bh_enable(); sock_put(sk); tcp_close() is a member of struct proto tcp_prot, which is defined in net/ipv4/tcp_ipv4.c. tcp_prot is assigned to sk->prot in net/ipv4/af_inet.c:inet_create(). sk->prot = prot; net/af_inet.c:inet_release() calls the close function of the struct sock's struct proto (sk->prot): sk->prot->close(sk, timeout); To wrap things up (for an AF_INET, SOCK_STREAM socket), the above line calls tcp_close(), which calls sock_put(sk), which calls sk_free(). Hope this helps. Regards, Nick Dronen - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org