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

📄 accept.2

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 2
字号:
.\" SCCSID: @(#)accept.2	6.2	8/29/89.TH accept 2.SH Nameaccept \- accept a connection on a socket.SH Syntax.ft B.nf#include <sys/types.h>#include <sys/socket.h>.PP.ft Baccept(s, addr, addrlen)int ns, s;struct sockaddr *addr;int *addrlen;.fi.SH Description.NXR "accept system call".NXR "socket" "accepting connection"The .PN acceptsystem call accepts a connection on a socket. The argument.I sis a socket that has been created with the.PN socket ,call, bound to an address with the.PN bind  ,call and is listening for connections after a .PN listen call.The .PN acceptsystem call extracts the first connectionon the queue of pending connections, createsa new socket with the same properties of .I sand allocates a new file descriptor,.IR ns ,for the socket.  If no pending connections arepresent on the queue, and the socket is not markedas nonblocking,.PN acceptblocks the caller until a connection is present.If the socket is marked nonblocking and no pendingconnections are present on the queue, .PN acceptreturns an error. The accepted socket,.IR ns ,cannot be usedto accept more connections.  The original socket.B sremains open..PPThe argument.I addris a result parameter that is filled in withthe address of the connecting entity,as known to the communications layer.The exact format of the.I addrparameter is determined by the domain in which the communicationis occurring.The .I addrlenis a value-result parameter; it should initially contain theamount of space pointed to by.IR addr .On return, .IR addrcontains the actual length in bytes of theaddress returned.This callis used with connection-based socket types, currently with SOCK_STREAM..PPYou can use the  .PN select call for the purposes of doing an.PN acceptcall by selecting the socket for reading..SH Return ValuesThe call returns \-1 on error.  If the call succeeds, it returns a non-negativeinteger which is a descriptor for the accepted socket..SH DiagnosticsThe .PN acceptcall fails if:.TP 15[EBADF]The descriptor is invalid..TP 15[ENOTSOCK]The descriptor references a file, not a socket..TP 15[EOPNOTSUPP]The referenced socket is not of type SOCK_STREAM..TP 15[EFAULT]The \fIaddr\fP parameter is not in a writable part of theuser address space..TP 15[EWOULDBLOCK]The socket is marked nonblocking and no connectionsare present to be accepted..SH See Alsobind(2), connect(2), listen(2), select(2), socket(2)

⌨️ 快捷键说明

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