📄 intro.3n
字号:
.\" SCCSID: @(#)intro.3n 8.1 9/11/90.TH intro 3n.SH Nameintro \- introduction to network library functions.SH Description.NXR "intro(3n) keyword".NXR "IPC" "library functions".NXS "interprocess communication facility" "IPC"This section describes functions that are available for interprocess communication (IPC). IPC takesplace using sockets. The.MS socket 2system call creates a communications channel basedon domain, type, and protocol. .PPSockets are created without names. The.MS bind 2system call is used to connect a name to a socket..PPA connection with another process must be madebefore data can be transferred on a bound socket. The.MS connect 2system call is used to rendezvous with another process. Thisprocess must be listening on a bound socket using the.MS listen 2system call. This listening process can accepta connection request using the.MS accept 2system call..PPOnce two processes have connected and accepted an IPC,data can be transferred with the following system calls:.MS read 2 ;.MS write 2 ;.MS send 2 ,and.MS recv 2 ..PPConnectionless sockets are also possible (a socket isbound and data can be transferred). They use thefollowing system calls to transfer data: .PN sendtoand.PN recvfrom ..PPIPC operates in three domains:.TP 17 UNIX\^Local node.TPINTERNET\^Local area network (LAN).TPDECNET\^DECnet network.PPThese types of sockets are available for IPC:.TP 17.I stream\^Sequenced, reliable, unduplicated data.brCONNECTED socket.brrecord boundaries not preserved.brall domains.TP.I datagram\^Not guaranteed to be sequenced, reliable, or.brunduplicated.bruser protocol needed to give guarantees.brUNCONNECTED socket.brrecord boundaries preserved.brUNIX and INTERNET domains.TP.I sequenced packet\^Like stream socket, except record boundaries preserved.brDECNET domain only.TP.I raw\^Access to communications protocols.SH Internet Addresses Routines The .I inetroutines manipulate Internet addresses..SH Network Data Base File RoutinesStandard mapping routines are used to retrieve entries in network data base files. Several routines operating on each data base file are identified by a group name:.TP 17.PN gethostent\^Retrieves entries from .PN /etc/hosts.TP .PN getnetent\^Retrieves entries from.PN /etc/networks.TP .PN getprotoent\^Retrieves entries from.PN /etc/protocols.TP .PN getservent\^Retrieves entries from.PN /etc/services.PPSpecific routines perform particular operationson each data base file:.TP 17 .PN get...ent\^Reads the next line of the file; opensthe file, if necessary..TP.PN set...ent\^Opens and rewinds the file..TP .PN end...ent\^Closes the file..TP .PN get...byname\^Searches the file sequentially from the beginninguntil a matching .I nameis found, or EOF isencountered..TP .PN get...byaddr\^Searches the file sequentially from the beginninguntil a matching .I addressis found, or EOF isencountered..TP .PN get...byport\^Searches the file sequentially from the beginninguntil a matching .I port numberis found, or EOF is encountered..TP .PN get...bynumber\^Searches the file sequentially from the beginninguntil a matching .I protocol numberis found, or EOF is encountered..PPEach network library routine returns a pointerto a structure reflecting individual fields of aline in one of the network data base files. Thestructure for each data base file contains some ofthe fields in the following list, with the prefix\fIx\fR replaced by a different letter in each file:.TP 17.PN x_addr\^pointer to a network address,returned in network-byte order.TP .PN x_addrtype\^address family of the address being returned.TP .PN x_aliases\^alternate names.TP .PN x_length\^length of an address, in bytes.TP .PN x_name\^official name.TP .PN x_net\^network number, returned in machine-byte order.TP .PN x_port\^resident port.TP .PN x_proto\^protocol number
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -