I'm mostly curious, but why aren't network interfaces in /dev? Are there any other kinds of devices that aren't represented as a node under /dev?
|
On many devices, the main operations are to send bytes from the computer to a peripheral, or to receive bytes from a peripheral on the computer. Such devices are similar to pipes and work well as character devices. For operations that aren't reading and writing (such as flow control on a serial line), the device provides ad-hoc commands called ioctl. Some devices are very much like regular files: they're made of a finite number of bytes, and what you write at a given position can later be read from the same position. These devices are called block devices. Network interfaces are more complex: what they read and write is not bytes but packets. While it would still be possible to use the usual interface with Network interfaces could exist as devices providing only Most network-related applications don't care about individual network interfaces, they work at a higher level. For example, a web browser wants to make TCP connections, and a web server wants to listen for TCP connections. For this purpose, what would be useful is devices for high-level network protocols, e.g.
In fact ksh and bash provide such an interface for TCP and UDP clients. In general, however, network applications are more complex than file-accessing applications. While most data exchanges are conducted with calls analogous to Another class of devices that typically doesn't have entries in |
|||
|
|
|
The AT&T/Solaris "Transport Level Interface" (TLI) way of doing TCP/IP networking has special files like "/dev/tcp" or "/dev/udp". The programmer opens that special file to get a socket of an appropriate protocol family. I think that's why you have to have "-lnsl" when compiling a program that uses sockets on Solaris: underneath it all it's TLI. |
|||||
|
|
You can find it in
|
|||||
|
|
While traditionally Linux has not been fully posix compablible, let alone even follow any kind of Open Group standards(outside of maybe LSB). There has been attempts to port more UNIX functionality into Linux. Glendix is one such project that offers a port of the /net virtual filesystem from Plan9 which allows you to do just as your describing. |
|||
|
|
read()andwrite()the same way that you would on a file, but the utility functionsrecv()andsend()do a lot more legwork for you. – jgoldschrafe Oct 26 '11 at 1:48