There is a task to create a model of sockets, purely for research purposes (So why, and it’s better not to ask questions). Since the UNIX file system "Everything is a file", including sockets, can I take a look at them? What are they made of? Their structure and so on, in order to get closer to the real model, if I am mistaken about something, I will be glad to hear how it actually works.

1 answer 1

Once in the UNIX file system, "Everything is a file," including sockets, ... What are they made of?

For a start, all special files in a file system (devices, sockets, named pipes) are just a file descriptor that does not have any associated data in the file system itself. those. the question “what are they made of?” makes no more sense than “what’s in the empty bag?”.

Since the UNIX file system "Everything is a file", including sockets, can I take a look at them?

Generally speaking, it is not; more specifically, it depends on what kind of sockets we are talking about, if the usual "Internet sockets" for TCP / UDP / IPX / something-more-weird, they are in most implementations are not associated with any file in FS If we are talking about Unix sockets (Unix Domain Socket or local IPC sockets), then the file specified during the bind of the socket is created for them. Traditionally, most of those are located in /var/run . But again, this is a pure abstraction in the memory of the kernel and there is no structure on the disk.

There is a task to create a model of sockets, purely for research purposes (So why, and it’s better not to ask questions).

The phrase sounds quite meaningless, so that some explanation here would not hurt ..

  • That's the point, so far I have a mess in my head, and I would like to structure it all, now there are more questions, the task is to make an OSI model, the information is how it works, but how does the interaction go between everything, roughly speaking, ip- Adders, if there is a unique Mac-address of each company, well, there are many such stupid questions, and I would like to figure it all out, at the moment there is laboratory work in the university where you need to simulate the data link layer, but the main question is ip-address in this model, if the channel ur Is the ram on him exactly? - Robert Guthrie
  • I guess I did not formulate the right question, I would need to know how a socket is created at all, if it is an abstraction, then by what principle does it work, and so on. Just one thing, if I use ready-made functions in the C language, and another thing, if I know how they work. Just want to deal with networks, but with roots :) - Robert Guthrie
  • @RobertGatry, a socket is a purely software interface, a convenient abstraction and API for a programmer. to the way network protocols work, they have a very superficial relationship; how the sockets are implemented in detail - depends on the OS, usually it doesn’t interest anyone, so the main source of information on this issue will be the source ... Usually people are interested in two neighboring levels: details of what API the socket subsystem provides (functions C and their expected behavior) and implementation details of the underlying protocols that are used for transmission over the network. - Fat-Zer
  • @RobertGatry, for general introduction, I advise you first to read some book. I can recommend D ... E. Kamer - "TCP / IP networks". - Fat-Zer
  • @RobertGatry, regarding the questions, what stupid is nothing, but it is desirable to formulate them clearly and they should be specific (do not require writing a whole book to answer); all controversial statements it is desirable to bring with the sequence of conclusions that led to them or the source; whenever possible, it is advisable to supply examples and adhere to the principle of one post - one question. But the questions from the series “What is expected of me in this laboratory?” Are better addressed to the teacher / training manual / colleagues and it will be more practical to find out before asking how “how to do it?”. - Fat-Zer