0

I need to open multiple TCP sockets, corresponding to each namespace programmed in linux.
I wanted to know whether the fd assigned to these sockets might be the same or they are always system-wide unique?

chrk
  • 4,037
  • 2
  • 39
  • 47
rango
  • 311
  • 1
  • 13

1 Answers1

0

A given process can only be a member of one namespace. A file descriptor is only relevant within the context of one process.

If one process creates several sockets, those file descriptors are known only to that process, and are not useful to outside processes (apart from diagnostic tools like /proc/PID/fd).

If you have sockets created in two different namespaces, then by definition they are created in two different processes and therefore the file descriptors need not be (and likely will not be) unique.

If you want something globally unique, you might be interested in the socket "inodes." You can read about how to list those here: How do I find the inode of a TCP socket? . I suspect, but haven't verified, that those inode numbers would be unique on a machine, regardless of namespace.

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436