161599Sbostic.\" Copyright (c) 1985, 1991, 1993 261599Sbostic.\" The Regents of the University of California. All rights reserved. 324107Ssklower.\" 443581Strent.\" %sccs.include.redist.man% 524107Ssklower.\" 6*66966Sbostic.\" @(#)spp.4 8.2 (Berkeley) 04/19/94 736752Sbostic.\" 847675Scael.Dd 947675Scael.Dt SPP 4 1047675Scael.Os BSD 4.3 1147675Scael.Sh NAME 1247675Scael.Nm spp 1347675Scael.Nd Xerox Sequenced Packet Protocol 1447675Scael.Sh SYNOPSIS 1547675Scael.Fd #include <sys/socket.h> 1647675Scael.Fd #include <netns/ns.h> 1747675Scael.Fd #include <netns/sp.h> 1847675Scael.Ft int 1947675Scael.Fn socket AF_NS SOCK_STREAM 0 2047675Scael.Ft int 2147675Scael.Fn socket AF_NS SOCK_SEQPACKET 0 2247675Scael.Sh DESCRIPTION 2347675ScaelThe 2447675Scael.Tn SPP 2547675Scaelprotocol provides reliable, flow-controlled, two-way 2624107Ssklowertransmission of data. It is a byte-stream protocol used to 2747675Scaelsupport the 2847675Scael.Dv SOCK_STREAM 2947675Scaelabstraction. 3047675Scael.Tn SPP 3147675Scaeluses the standard 3247675Scael.Tn NS Ns (tm) 3347675Scaeladdress formats. 3447675Scael.Pp 3547675ScaelSockets utilizing the 3647675Scael.Tn SPP 3747675Scaelprotocol are either 3847675Scael.Dq active 3947675Scaelor 4047675Scael.Dq passive . 4147675ScaelActive sockets initiate connections to passive 4247675Scaelsockets. By default 4347675Scael.Tn SPP 4447675Scaelsockets are created active; to create a 4524107Ssklowerpassive socket the 4647675Scael.Xr listen 2 4724107Ssklowersystem call must be used 4824107Ssklowerafter binding the socket with the 4947675Scael.Xr bind 2 5024107Ssklowersystem call. Only 5124107Ssklowerpassive sockets may use the 5247675Scael.Xr accept 2 5324107Ssklowercall to accept incoming connections. Only active sockets may 5424107Sskloweruse the 5547675Scael.Xr connect 2 5624107Ssklowercall to initiate connections. 5747675Scael.Pp 5847675ScaelPassive sockets may 5947675Scael.Dq underspecify 6047675Scaeltheir location to match 6124107Ssklowerincoming connection requests from multiple networks. This 6247675Scaeltechnique, termed 6347675Scael.Dq wildcard addressing , 6447675Scaelallows a single 6524107Ssklowerserver to provide service to clients on multiple networks. 6647675ScaelTo create a socket which listens on all networks, the 6747675Scael.Tn NS 6824107Sskloweraddress of all zeroes must be bound. 6947675ScaelThe 7047675Scael.Tn SPP 7147675Scaelport may still be specified 7224107Ssklowerat this time; if the port is not specified the system will assign one. 7324107SsklowerOnce a connection has been established the socket's address is 7424107Ssklowerfixed by the peer entity's location. The address assigned the 7524107Ssklowersocket is the address associated with the network interface 7624107Ssklowerthrough which packets are being transmitted and received. Normally 7724107Ssklowerthis address corresponds to the peer entity's network. 7847675Scael.Pp 7947675ScaelIf the 8047675Scael.Dv SOCK_SEQPACKET 8147675Scaelsocket type is specified, 8224107Ssklowereach packet received has the actual 12 byte sequenced packet header 8324107Ssklowerleft for the user to inspect: 8447675Scael.Bd -literal -offset indent 8524107Ssklowerstruct sphdr { 8647675Scael u_char sp_cc; /* connection control */ 8747675Scael#define SP_EM 0x10 /* end of message */ 8847675Scael u_char sp_dt; /* datastream type */ 8924107Ssklower u_short sp_sid; 9024107Ssklower u_short sp_did; 9124107Ssklower u_short sp_seq; 9224107Ssklower u_short sp_ack; 9324107Ssklower u_short sp_alo; 9424107Ssklower}; 9547675Scael.Ed 9647675Scael.Pp 9724107SsklowerThis facilitates the implementation of higher level Xerox protocols 9824107Ssklowerwhich make use of the data stream type field and the end of message bit. 9924107SsklowerConversely, the user is required to supply a 12 byte header, 10024107Ssklowerthe only part of which inspected is the data stream type and end of message 10124107Ssklowerfields. 10247675Scael.Pp 10324107SsklowerFor either socket type, 10424107Ssklowerpackets received with the Attention bit sent are interpreted as 10547675Scaelout of band data. Data sent with 10647675Scael.Dq send(..., ..., ..., Dv MSG_OOB ) 10724107Ssklowercause the attention bit to be set. 10847675Scael.Sh DIAGNOSTICS 10924107SsklowerA socket operation may fail with one of the following errors returned: 11047675Scael.Bl -tag -width [EADDRNOTAVAIL] 11147675Scael.It Bq Er EISCONN 11224107Ssklowerwhen trying to establish a connection on a socket which 11324107Sskloweralready has one; 11447675Scael.It Bq Er ENOBUFS 11524107Ssklowerwhen the system runs out of memory for 11624107Sskloweran internal data structure; 11747675Scael.It Bq Er ETIMEDOUT 11824107Ssklowerwhen a connection was dropped 11924107Ssklowerdue to excessive retransmissions; 12047675Scael.It Bq Er ECONNRESET 12124107Ssklowerwhen the remote peer 12224107Ssklowerforces the connection to be closed; 12347675Scael.It Bq Er ECONNREFUSED 12424107Ssklowerwhen the remote 12524107Ssklowerpeer actively refuses connection establishment (usually because 12624107Ssklowerno process is listening to the port); 12747675Scael.It Bq Er EADDRINUSE 12824107Ssklowerwhen an attempt 12924107Sskloweris made to create a socket with a port which has already been 13024107Ssklowerallocated; 13147675Scael.It Bq Er EADDRNOTAVAIL 13224107Ssklowerwhen an attempt is made to create a 13324107Ssklowersocket with a network address for which no network interface 13424107Ssklowerexists. 13547675Scael.El 13647675Scael.Sh SOCKET OPTIONS 13747675Scael.Bl -tag -width SO_DEFAULT_HEADERS 13847675Scael.It Dv SO_DEFAULT_HEADERS 13924107Ssklowerwhen set, this determines the data stream type and whether 14024107Ssklowerthe end of message bit is to be set on every ensuing packet. 14147675Scael.It Dv SO_MTU 142*66966SbosticThis specifies the maximum amount of user data in a single packet. 14324864SsklowerThe default is 576 bytes - sizeof(struct spidp). This quantity 14447675Scaelaffects windowing \- increasing it without increasing the amount 14524864Ssklowerof buffering in the socket will lower the number of unread packets 14624864Sskloweraccepted. Anything larger than the default will not be forwarded 14747675Scaelby a bona fide 14847675Scael.Tn XEROX 14947675Scaelproduct internetwork router. 15024864SsklowerThe data argument for the setsockopt call must be 15124864Sskloweran unsigned short. 15247675Scael.El 15347675Scael.Sh SEE ALSO 15447675Scael.Xr intro 4 , 15547675Scael.Xr ns 4 15647675Scael.Sh HISTORY 15747675ScaelThe 15847675Scael.Nm 15947675Scaelprotocol appeared in 16047675Scael.Bx 4.3 . 16147675Scael.Sh BUGS 16224107SsklowerThere should be some way to reflect record boundaries in 16324107Ssklowera stream. 16424107SsklowerFor stream mode, there should be an option to get the data stream type of 16524107Ssklowerthe record the user process is about to receive. 166