Open (), read (), write (), close () can be applied to all file types such as pipe, fifo,socket, or terminal to perform IO operations.
Lseek () does not apply to all types of files. Lseek () is not allowed to be applied to pipes, fifo,socket or terminals, and lseek can be applied to the device as long as it is reasonable. For example, find a specific location on a disk or tape.
CP Test Test.old
CP test/dev/pts/0
cp/dev/pts/0 Test
cp/dev/pts/0/DEV/PTS/1
[Email protected] pts]# echo "Wo shi" >/dev/pts/0
[Email protected] ~]# CP/DEV/PTS/1 b.txt
Fjei
Sfoei
Rifeo
Wfowef
[email protected] ~]# cat B.txt
Fjei
Sfoei
Rifeo
Wfowef
/usr/include/netinet/in.h
/* Structure describing an Internet socket address. */
struct SOCKADDR_IN
{
__sockaddr_common (Sin_);
in_port_t Sin_port; /* Port number. */
struct IN_ADDR sin_addr; /* Internet address. */
/* Pad to size of ' struct sockaddr '. */
unsigned char sin_zero[sizeof (struct sockaddr)-
__sockaddr_common_size-
sizeof (in_port_t)-
sizeof (struct in_addr)];
};
/* Ditto, for IPV6. */
struct SOCKADDR_IN6
{
__sockaddr_common (sin6_);
in_port_t Sin6_port; /* Transport Layer Port # */
uint32_t Sin6_flowinfo; /* IPV6 Flow information */
struct IN6_ADDR sin6_addr; /* IPV6 Address */
uint32_t sin6_scope_id; /* IPV6 Scope-id */
};
/usr/include/sys/socket.h
/* Create A new socket of type type in domain domain, using
Protocol protocol. If PROTOCOL is zero, the one is chosen automatically.
Returns a file descriptor for the new socket, or-1 for errors. */
extern int socket (int __domain, int __type, int __protocol) __throw;
Socketpair () system calls can only be used in Unix domain,
/* Create new sockets, of type type in domain domain and using
Protocol protocol, which is connected to all other, and put file
Descriptors for them in fds[0] and fds[1]. If PROTOCOL is zero,
One'll be chosen automatically. Returns 0 on success,-1 for errors. */
extern int Socketpair (int __domain, int __type, int __protocol,
int __fds[2]) __throw;
Linux Universal IO