title: How do I find the inode of a TCP socket?
body: <p>How do I tie values in the 'inode' column of <code>/proc/net/tcp</code> to files in <code>/proc/&lt;pid&gt;/fd/</code>?</p>
  
  <p>I was under the impression that the <code>inode</code> column in the TCP had a decimal representation of the socket's inode, but that doesn't seem to be the case. </p>
  
  <p>For example, if I run <code>telnet localhost 80</code>, I see the following (telnet is pid 9021).</p>
  
  <p><code>/proc/net/tcp</code> contains </p>
  
  <pre><code>sl  local_address rem_address   st tx_queue rx_queue tr tm-&gt;when retrnsmt   uid  timeout inode
  23: 0100007F:CE2A 0100007F:0050 01 00000000:00000000 00:00000000 00000000  1000        0 361556 1 00000000 20 0 0 10 -1
  </code></pre>
  
  <p>which makes me think that the inode of the socket connected to 127.0.0.1:80 is 361556. But if I run <code>ls --inode -alh /proc/9021/fd</code>, I see</p>
  
  <pre><code>349886 lrwx------ 1 me me 64 Dec 26 10:51 3 -&gt; socket:[361556]
  </code></pre>
  
  <p>The inode is 349886, which is different from the value in the inode column of the tcp table: 361556. But the link target seems to have the right name. Similarly, <code>stat /proc/9021/3</code> shows:</p>
  
  <pre><code>File: ‘/proc/9021/fd/3’ -&gt; ‘socket:[361556]’
  Size: 64            Blocks: 0          IO Block: 1024   symbolic link
  Device: 3h/3d   Inode: 349886      Links: 1
  </code></pre>
  
  <p>What's the number in the inode column of tcp table? Why doesn't it line up with the inode as reported by <code>ls</code> or <code>stat</code>?</p>
  
  <p>(I'm running Ubuntu 14.10, if that matters)</p>