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

📄 trans_serv.nr

📁 早期freebsd实现
💻 NR
📖 第 1 页 / 共 2 页
字号:
\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".ppThe system calls provided by AOS for data transfer havesemantics that are unsuitable for TP,and in fact they are seriously deficient for the correctoperation of any user program that uses out-of-band or expediteddata in any way except to cause the program to abort.The problem lies in the manner in which the kernelhandles 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 or receive primitive is interrupted before completion,the user needs to know how many octets of data were sent or received.The existing system call interface does not provide thisinformation, nor does it permit TP to providethis information.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 return an errorindication (-1, \fIerrno\fR == EINTR) if the system call is interrupted. To change the semanticsof these calls would create havoc with existing user-level software.Instead two new system calls are provided to support data transfer.(The existing interface may be used if the user does not need the additionalservice provided by the new system calls.).ppThe two new system calls are patterned after \fIreadv()\fR and \fIwritev()\fR,the scatter-gather or "vectored"versions of \fIread()\fR and \fIwrite()\fR..(b\fC.TStab(+);l s s s.cc = sendv( s, iov, iovlen, flags ).T&l l l. +int+s: +io_vector+iov; +int+iovlen; +unsigned int+*flags;.TE\fR.)b.(b\fC.TStab(+);l s s s.cc = recvv( s, iov, iovlen, flags ).T&l l l. +int+s: +io_vector+iov; +int+iovlen; +unsigned int+*flags;.TE\fR.)b.ppThe \fIiov\fR argument is an \fIio_vector\fR,an array of pointers and lengths thatdescribe the areas from (or to) which the data will be gathered (or scattered).The \fIiovlen\fR argument is an integer that tells how many parts are inthe io_vector.The \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 both sending andreceiving.This way one TSDU can span several system calls.When sending, the user setsthis flagto indicate that this  request completes a TSDU.When receiving, TP sets this flag whenthe end of a TSDU is reached.In the latter case, the end of the data received by the transport userwith a given system callcoincides with the end of the TSDUif the TP has set the end-of-TSDU bitin the \fIflags\fR parameter of the \fIrecv()\fR system call.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.See the manual pages \fIrecvv(2)\fR and\fIsendv(2)\fR for details..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".ppWhile the above set of system calls allows you to establisha connection, transfer data, and disconnect, several elements of the transport service are not supportedby these system calls alone.These system calls do not support any way to indicate to theto the transport userthepresence of expedited data ora disconnection initiated by the peer or by one of thecooperating TP entities..ppThe Unix signal mechanism is used to provide theseservice elements.When an expedited data TSDU arrives, the TP interruptsthe 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 discards all queued normal data and expedited data.It saves the disconnect data for the user to receive via the\fIgetsockopt()\fR system call.Unfortunately, the socket is already considered closedby the kernel, so there is no wayfor the user to read the incoming disconnect data, so receiptof disconnect data is not supported..\".\"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 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 + -