When I use nc to listen a port , it shows
nc -l -vv -p 21000
retrying local 0.0.0.0:21000 : Address already in use Can't grab 0.0.0.0:21000 with bind
But I can not find which task occupy's this port with tools netstat / ss
netstat -an|grep 21000 
;nothing find
ss -a|grep 21000 
;nothing find
This port is occupied by my java program, the code is :
public class Test1 {
        public static void main(String[] args) throws InterruptedException {
        Socket s = new Socket();
        try {
            s.bind(new InetSocketAddress("127.0.0.1",21000));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Thread.sleep(500000000000L);
    }
}
when I bind a socket ,but do not use it with connect or listen. I get into the /proc/[java task id]/fd , find the inode of this socket is "socket:[3073501]" but I can't find the inode or port even in /proc/net/tcp or /proc/net/tcp6
Is there any method to find the process which bind's the socket but does not listen or connect.
Thanks.
I see linux 3.10.0-327 source code. I think the content of the file /proc/net/tcp come from the net/ipv4/tcp_ipv4.c.
in tcp_proc_register method,
static void *tcp_get_idx(struct seq_file *seq, loff_t pos)      
{
        void *rc;
        struct tcp_iter_state *st = seq->private;
        st->state = TCP_SEQ_STATE_LISTENING;
        rc        = listening_get_idx(seq, &pos);
        if (!rc) {
                st->state = TCP_SEQ_STATE_ESTABLISHED;
                rc        = established_get_idx(seq, pos);
        }
        return rc;
}
It shows only the socks in listening or established from tcp_hashinfo. But tcp_hashinfo has three struct
struct inet_bind_hashbucket     *bhash; 
struct inet_listen_hashbucket   listening_hash[INET_LHTABLE_SIZE];
struct inet_ehash_bucket        *ehash;
bhash may be used for binding. But is does not export in /proc/net/tcp.
 
    