1 /****** bsdsocket.library/Errno *********************************************
4 * Errno - get error value after unsuccessful function call
13 * When some function in socket library return an error
14 * condition value, they also set a specific error value. This
15 * error value can be extracted by this function.
18 * Error value indicating the error on last failure of some
19 * socket function call.
22 * Return value of Errno() is not changed after successful
23 * function so it cannot be used to determine success of any
24 * function call of this library. Also, another function call
25 * to this library may change the return value of Errno() so
26 * use it right after error occurred.
31 *****************************************************************************
36 /****** bsdsocket.library/ObtainSocket **************************************
39 * ObtainSocket - get a socket from AmiTCP/IP socket list
42 * s = ObtainSocket(id, domain, type, protocol)
45 * LONG ObtainSocket(LONG, LONG, LONG, LONG);
48 * When one task wants to give a socket to an another one, it
49 * releases it (with a key value) to a special socket list held
50 * by AmiTCP/IP. This function requests that socket and
51 * receives it if id and other parameters match.
54 * id - a key value given by the socket donator.
55 * domain - see documentation of socket().
56 * type - see documentation of socket().
57 * protocol - see documentation of socket().
60 * Non negative socket descriptor on success. On failure, -1 is
61 * returned and the errno is set to indicate the error.
64 * EMFILE - The per-process descriptor table is
67 * EPROTONOSUPPORT - The protocol type or the specified pro-
68 * tocol is not supported within this
71 * EPROTOTYPE - The protocol is the wrong type for the
74 * EWOULDBLOCK - Matching socket is not found.
77 * ReleaseCopyOfSocket(), ReleaseSocket(), socket()
79 *****************************************************************************
83 /****** bsdsocket.library/ReleaseCopyOfSocket *******************************
86 * ReleaseCopyOfSocket - copy given socket to AmiTCP/IP socket list.
89 * id = ReleaseCopyOfSocket(fd, id)
92 * LONG ReleaseCopyOfSocket(LONG, LONG);
95 * Make a new reference to a given socket (pointed by its descriptor)
96 * and release it to the socket list held by AmiTCP/IP.
99 * fd - descriptor of the socket to release.
101 * id - the key value to identify use of this socket. It can be
102 * unique or not, depending on its value. If id value is
103 * between 0 and 65535, inclusively, it is considered
104 * nonunique and it can be used as a port number, for
105 * example. If id is greater than 65535 and less than
106 * 2^31) it must be unique in currently held sockets in
107 * AmiTCP/IP socket list, Otherwise an error will be
108 * returned and socket is not released. If id ==
109 * UNIQUE_ID (defined in <sys/socket.h>) an unique id will
113 * id - -1 in case of error and the key value of the socket put
114 * in the list. Most useful when an unique id is generated
118 * EINVAL - Requested unique id is already used.
120 * ENOMEM - Needed memory couldn't be allocated.
123 * The socket descriptor is not deallocated.
126 * ObtainSocket(), ReleaseSocket()
129 *****************************************************************************
133 /****** bsdsocket.library/ReleaseSocket *************************************
136 * ReleaseSocket - release given socket to AmiTCP/IP socket list.
139 * id = ReleaseSocket(fd, id)
142 * LONG ReleaseSocket(LONG, LONG);
145 * Release the reference of given socket (via its descriptor)
146 * and move the socket to the socket list held by AmiTCP/IP.
147 * The socket descriptor is deallocated in this procedure.
150 * fd - descriptor of the socket to release.
152 * id - the key value to identify use of this socket. It can be
153 * unique or not, depending on its value. If id value is
154 * between 0 and 65535, inclusively, it is considered
155 * nonunique and it can be used as a port number, for
156 * example. If id is greater than 65535 and less than
157 * 2^31) it must be unique in currently held sockets in
158 * AmiTCP/IP socket list, Otherwise an error will be
159 * returned and socket is not released. If id ==
160 * UNIQUE_ID (defined in <sys/socket.h>) an unique id will
164 * id - -1 in case of error and the key value of the socket put
165 * in the list. Most useful when an unique id is generated
169 * EINVAL - Requested unique id is already used.
171 * ENOMEM - Needed memory couldn't be allocated.
174 * ObtainSocket(), ReleaseCopyOfSocket()
176 *****************************************************************************
180 /****** bsdsocket.library/SetErrnoPtr ***************************************
183 * SetErrnoPtr - set new place where the error value will be written
186 * SetErrnoPtr(ptr, size)
189 * VOID SetErrnoPtr(VOID *, UBYTE);
192 * This functions allows caller to redirect error variable inside
193 * scope of caller task. Usually this is used to make task's
194 * global variable errno as error variable.
197 * ptr - pointer to error variable that is to be modified on
198 * every error condition on this library function.
199 * size - size of the error variable.
205 * struct Library * SocketBase = NULL;
210 * if ((SocketBase = OpenLibrary("bsdsocket.library", 2))
212 * SetErrnoPtr(&errno, sizeof(errno));
218 * Be sure that this new error variable exists until library base
219 * is finally closed or SetErrnoPtr() is called again for another
225 *****************************************************************************
229 /****** bsdsocket.library/SetSocketSignals **********************************
232 * SetSocketSignals - inform AmiTCP/IP of INTR, IO and URG signals
235 * SetSocketSignals(sigintrmask, sigiomask, sigurgmask)
238 * VOID SetSocketSignals(ULONG, ULONG, ULONG);
241 * SetSocketSignals() tells the AmiTCP/IP which signal masks
242 * corresponds UNIX SIGINT, SIGIO and SIGURG signals to be used
243 * in this implementation. The sigintrmask mask is used to
244 * determine which Amiga signals interrupt blocking library
247 * The sigiomask is sent when asynchronous notification of
248 * socket events is done, the sigurgmask is sent when
249 * out-of-band data arrives, respectively. The signals are
250 * sent only to the owning task of particular socket. The
251 * socket has got no owner by default; the owner is set by
252 * FIOSETOWN (SIOCSPGRP) ioctl call.
254 * Note that the supplied values write over old ones. If this
255 * function is used and CTRL-C is still wanted to interrupt the
256 * calls (the default behaviour), the value BREAKF_CTRL_C must
257 * be explicitly given.
260 * The function SetSocketSignals() is obsoleted by the function
264 * IoctlSocket(), recv(), send(), select(), WaitSelect()
266 *****************************************************************************