⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trans_serv.nr

📁 早期freebsd实现
💻 NR
📖 第 1 页 / 共 2 页
字号:
.(b\fC.TStab(+);l s s s.status = getsockname( s, addr, addrlen ).T&l l l. +int+s; +struct sockaddr+*addr; +int+addrlen;.TE\fR.)b.ppIf the socket has a peer, that is, it is connected,the system call\fIgetpeername()\fRis used to discover the peer's address..(b\fC.TStab(+);l s s s.status = getpeername( s, addr, addrlen ).T&l l l. +int+s; +struct sockaddr+*addr; +int+addrlen;.TE\fR.)b.lpThe names returned by \fIgetsockname()\fR and \fIgetpeername()\fR do not contain extended TSELs.Extended TSELs can be retrieved with the \fIgetsockopt()\fR and \fIsetsockopt()\fR system calls, described below..ppUnix supports several protocol-independent optionsand protocol-specific optionsassociated with sockets.These options can be inspected and changed by usingthe \fIgetsockopt()\fR and \fIsetsockopt()\fR system calls..(b\fC.TStab(+);l s s s.status = getsockopt( s, level, option, value, valuelen ).T&l l l. +int+s, level, option; +char+*value; +int+*valuelen;.TE\fR.)b.(b\fC.TStab(+);l s s s.status = setsockopt( s, level, option, value, valuelen ).T&l l l. +int+s, level, option; +char+*value; +int+valuelen;.TE\fR.)b.ppThe \fIlevel\fR argument may indicateeitherthat this option applies to sockets or that it applies toa specific protocol.The constants SOL_SOCKET, SOL_TRANSPORT, and SOL_NETWORKare possible values for the \fIlevel\fR argument.The \fIoption\fR argument is an integer that identifiesthe option chosen..\" LIST THE OPTIONS HEREThe options available to TP users provide the user with the ability to control various TP protocol optionsincluding but not limited toTP class, TPDU size negotiated, TPDU format used,acknowledgment and retransmission strategies.For a detail list of the options, see the manual page \fItp(4p)\fR..sh 1 "Extended TSELs".ppARGO supports TSELsof length 1 byte - 64 bytes for sockets bound to addresses in theAF_ISO address family.The ARGO user program uses the\fIgetsockopt()\fRand \fIsetsockopt()\fRsystem calls to discover and assign extended TSELs..ppTo create a socket with an extended TSEL,the process .ip \(bu 5opens a socket with \fCsocket(AF_ISO, SOCK_SEQPACKET, ISOPROTO_TP)\fR.ip \(bu 5binds an NSAP-address to the socket with \fIbind()\fR.The address bound may contain a 2-byte selector (\fIiso_tsuffix\fR)..ip \(bu 5uses \fIsetsockopt()\fR with the command TPOPT_MY_TSEL,to assign a TSEL to the socket..ip \(bu 5calls \fIlisten(), connect()\fR, or any other appopriate system callsto use the socket as desired..lpTo connect to a transport entity that is bound to a TSAP-address withan extended TSEL, theprocess .ip \(bu 5opens a socket with \fCsocket(AF_ISO, SOCK_SEQPACKET, ISOPROTO_TP)\fR.ip \(bu 5uses \fIsetsockopt()\fR, with the command TPOPT_PEER_TSEL,to assign a PEER TSEL to the socket.This TSEL is used by the transport entity for all subsequent connect requests made on this socket, unless the peer TSEL is changed by another call to\fIsetsockopt()\fR employing the command TPOPT_PEER_TSEL..lpTo discover the TSEL of the peer of a connected socket,the process .ip \(bu 5uses \fIgetsockopt()\fR with the command TPOPT_PEER_TSEL..lpTo discover the TSEL of socket's own address,the process .ip \(bu 5uses \fIgetsockopt()\fR with the command TPOPT_MY_TSEL..sh 1 "Data transfer".ppEarlier BSD-based systems have provided system calls for data transferhaving bugs and semantics that are problematic for TP.These should be correct as presented in the test system.The problem was in the manner in which the kernelhandled interrupted system calls.The send and receive primitivesmay be interrupted by signals.A signal is the mechanism used to indicatethe presence of expedited data or out-of-band data.If the send primitive as interrupted before completion,the user could not determine how many octets of data were sent.All forms of the existing interface (\fIsend()\fR, \fIrecv()\fR, \fIsendmsg()\fR, \fIrecvmsg()\fR, \fIsendto()\fR, \fIrecvfrom()\fR, \fIwrite()\fR, \fIread\fR, \fIwritev()\fR, and \fIreadv()\fR system calls)return an octet countwhen the system call completes, and to return a short countif the system call is interrupted. .ppThe system calls sendmsg and recvmsg have been revised to make them more convenient for receipt ofout of band data..(b\fC.TStab(+);l s s s.cc = sendmsg( s, msg, flags ).T&l l l. +int+s; +istruct msghdr+msg; +unsigned int+flags;.TE\fR.)b.(b\fC.TStab(+);l s s s.cc = recvmsg( s, msg, flags ).T&l l l. +int+s; +istruct msghdr+msg; +unsigned int+flags;.TE\fR.)b.ppThe reader should now consult the manual page for recvmsgfor an explanation of the elements of the msghdr structure,and how the calls may be used to glean user-connection-request data..ppThe \fIflags\fR parameter serves several purposes.The TP specification requires that TSDUs be unlimited in size.System calls cannot pass unlimited amounts of data between the userand the kernel, sothere cannot be a one-to-one correspondence between TSDUs andsystem calls. The \fIflags\fRparameter is used to mark the end-of-TSDU on sending data.When receiving, TP sets this bit in the flags element of the msghdr structurewhen the end of a TSDU is consumed.This way one TSDU can span several system calls.It is possible for the peer to send an empty TPDU with the end-of-TSDUflag set, in which case the transport usermay receive zero octets with the end-of-TSDU flag set..ppThe \fIflags\fR parameter also serves to distinguish data transfer primitivesfrom expedited data transfer primitives.The flag bit MSG_OOB is provided for "out of band data" in theDoD Internet protocols.  It is also used to provide the expedited data serviceof the ISO protocols.The transport layer will deliver one expedited datum (there will be aone-to-one correspondence between expedited TSDUs and XPD TPDUs)at a time.  The user must receive the datum before the transportlayer will accept more expedited data.Each expedited datum my contain up to 16 octets..pp.sh 1 "Disconnection".ppThe \fIclose\fR system call will disconnect any associationbetween two TP entities..(b\fC.TStab(+);l s s s.status = close( s ).T&l l l. +int+s;.TE\fR.)b.ppThe argument \fIs\fR is a socket descriptor.If a Unix user process terminates, Unix will close all files andsockets associated with the process, which means all transportconnections associated with the process will be disconnected..sh 1 "Indications from the transport layer to the transport user".ppThe above set of system calls allows you to establisha connection, transfer data, and disconnect. Thepresence or reception of expedited data is indicatedby TP setting the MSG_OOB bit in the flags element of the msg structure.A disconnection initiated by the peer or by one of thecooperating TP entities can be signalled by a control message,although we have not yet implemented this..ppThe Unix signal mechanism may be used to provide theseservice elements, as well.When an expedited data TSDU arrives, the TP may interruptthe user with a SIGURG signal ("urgent condition present on socket").The user must have previously registered a procedure to handlethe signal by using the \fIsigvec()\fR system call or the\fIsignal()\fR library routine provided for that purpose.The signal handler takes the form.(b\fC.TStab(+);l s s s.int  sighandler( signal_number).T&l l l. +int+signal_number;.TE\fR.)b.ppThe \fIsignal_number\fR argument will be the well-known constant SIGURG.There are two reasons for the transport layer to issuea SIGURG:  expedited dataare present ordisconnection was initiated by a transport entity or by the peer.Should the user have more than one transport connection open,another system call is used to determine to which socket(s)the urgent condition applies.This is the \fIselect()\fR system call, described below..ppWhen the SIGURG indicates a disconnection, there may beuser data from the peer present.TP saves the disconnect data for the user to receive via the\fIgetsockopt()\fR system call, or through the.IR recvmsg ()ancillary data mechanism..\".\"If the user does not receive the disconnect data before the.\"reference timer expires, the data will be discarded and the.\"socket will be closed..ppTransport service users may use more than one transportconnection at a time.The \fIselect()\fR system call facilitates this..(b\fC.TStab(+);l s s s.#include <sys/types.h>+nfound = select( num_to_scan, recvmask, sendmask, +exceptmask, timeout ).T&l l l. +int+nfound, num_to_scan; +fd_set+*recvmask, *sendmask, *exceptmask; +time+timeout;.TE\fR.)b.ppThis system call takes as parameters a set of masks that specify a subset of the socket descriptors that are inuse by the user program.\fISelect()\fR inspects the sockets to see if they have datato be received, can service a send without blocking, orhave an exceptional condition pending, respectively.The masks will be set upon return to indicate the socket descriptorsfor which the respective conditions exist.The \fInum_to_scan\fR argument limits the number of sockets that areinspected.The call will return within the amount of time given in the\fItimeout\fR parameter, or, if the parameter is zero, \fIselect()\fRwill block indefinitely..\" FIGURE.so ../wisc/figs/TS_primitives.nr.pp.CFsummarizes the mapping of the transport service primitivesto Unix facilities.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -