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

📄 socklib.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/sockLib.html - generated by refgen from sockLib.c --> <title> sockLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual :  Libraries</i></a></p></blockquote><h1>sockLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>sockLib</strong> - generic socket library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./sockLib.html#socket">socket</a></i>(&nbsp;)</b>  -  open a socket<br><b><i><a href="./sockLib.html#bind">bind</a></i>(&nbsp;)</b>  -  bind a name to a socket<br><b><i><a href="./sockLib.html#listen">listen</a></i>(&nbsp;)</b>  -  enable connections to a socket<br><b><i><a href="./sockLib.html#accept">accept</a></i>(&nbsp;)</b>  -  accept a connection from a socket<br><b><i><a href="./sockLib.html#connect">connect</a></i>(&nbsp;)</b>  -  initiate a connection to a socket<br><b><i><a href="./sockLib.html#connectWithTimeout">connectWithTimeout</a></i>(&nbsp;)</b>  -  try to connect over a socket for a specified duration<br><b><i><a href="./sockLib.html#sendto">sendto</a></i>(&nbsp;)</b>  -  send a message to a socket<br><b><i><a href="./sockLib.html#send">send</a></i>(&nbsp;)</b>  -  send data to a socket<br><b><i><a href="./sockLib.html#sendmsg">sendmsg</a></i>(&nbsp;)</b>  -  send a message to a socket<br><b><i><a href="./sockLib.html#recvfrom">recvfrom</a></i>(&nbsp;)</b>  -  receive a message from a socket<br><b><i><a href="./sockLib.html#recv">recv</a></i>(&nbsp;)</b>  -  receive data from a socket<br><b><i><a href="./sockLib.html#recvmsg">recvmsg</a></i>(&nbsp;)</b>  -  receive a message from a socket<br><b><i><a href="./sockLib.html#setsockopt">setsockopt</a></i>(&nbsp;)</b>  -  set socket options<br><b><i><a href="./sockLib.html#getsockopt">getsockopt</a></i>(&nbsp;)</b>  -  get socket options<br><b><i><a href="./sockLib.html#getsockname">getsockname</a></i>(&nbsp;)</b>  -  get a socket name<br><b><i><a href="./sockLib.html#getpeername">getpeername</a></i>(&nbsp;)</b>  -  get the name of a connected peer<br><b><i><a href="./sockLib.html#shutdown">shutdown</a></i>(&nbsp;)</b>  -  shut down a network connection<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides UNIX BSD 4.4 compatible socket calls.  Use these calls to open, close, read, and write sockets. These sockets can join processes on the same CPU or on different CPUs between which there is anetwork connection.  The calling sequences of these routines are identical to their equivalents under UNIX BSD 4.4.<p></blockquote><h4>ADDRESS FAMILY</h4><blockquote><p>VxWorks sockets support only the Internet Domain address family.  Use<b>AF_INET</b> for the <i>domain</i> argument in subroutines that require it.There is no support for the UNIX Domain address family.<p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>Sockets respond to the following <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b> functions.  These functions aredefined in the header files <b>ioLib.h</b> and <b>ioctl.h</b>.<dl><dt><b>FIONBIO</b><dd>Turns on/off non-blocking I/O.<pre>    on = TRUE;    status = ioctl (sFd, FIONBIO, &amp;on);</pre><dt><b>FIONREAD</b><dd>Reports the number of read-ready bytes available on the socket.  On the return of <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b>, <i>bytesAvailable</i> has the number of bytes available to read from the socket.<pre>    status = ioctl (sFd, FIONREAD, &amp;bytesAvailable);</pre><dt><b>SIOCATMARK</b><dd>Reports whether there is out-of-band data to be read from the socket.  Onthe return of <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b>, <i>atMark</i> is TRUE (1) if there is out-of-banddata.  Otherwise, it is FALSE (0).<pre>    status = ioctl (sFd, SIOCATMARK, &amp;atMark);</pre> </dl></blockquote><h4>INCLUDE FILES</h4><blockquote><p><p>&nbsp;<b>types.h</b>,&nbsp;<b>mbuf.h</b>,&nbsp;<b>socket.h</b>,&nbsp;<b>socketvar.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b>, <b><a href="./netLib.html#top">netLib</a></b>,  <i>VxWorks Programmer's Guide: Network</i><hr><a name="socket"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>socket</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>socket</i>(&nbsp;)</strong> - open a socket</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int socket    (    int domain,  /* address family (for example, AF_INET) */    int type,    /* SOCK_STREAM, SOCK_DGRAM, or SOCK_RAW */    int protocol /* socket protocol (usually 0) */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine opens a socket and returns a socket descriptor.The socket descriptor is passed to the other socket routines to identify thesocket.  The socket descriptor is a standard I/O system file descriptor(fd) and can be used with the <b><i><a href="./ioLib.html#close">close</a></i>(&nbsp;)</b>, <b><i><a href="./ioLib.html#read">read</a></i>(&nbsp;)</b>, <b><i><a href="./ioLib.html#write">write</a></i>(&nbsp;)</b>, and <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b> routines.<p>Available socket types include:<dl><dt><b>SOCK_STREAM</b><dd>Specifies a connection-based (stream) socket.<p><dt><b>SOCK_DGRAM</b><dd>Specifies a datagram (UDP) socket.<p><dt><b>SOCK_RAW</b><dd> Specifies a raw socket. </dl><p></blockquote><h4>RETURNS</h4><blockquote><p>A socket descriptor, or ERROR.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b><hr><a name="bind"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>bind</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>bind</i>(&nbsp;)</strong> - bind a name to a socket</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS bind    (    int               s,      /* socket descriptor */    struct sockaddr * name,   /* name to be bound */    int               namelen /* length of name */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine associates a network address (also referred to as its "name")with a specified socket so that other processes can connect or send to it.When a socket is created with <b><i><a href="./sockLib.html#socket">socket</a></i>(&nbsp;)</b>, it belongs to an address familybut has no assigned name.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>OK, or ERROR if there is an invalid socket, the address is eitherunavailable or in use, or the socket is already bound.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b><hr><a name="listen"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>listen</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>listen</i>(&nbsp;)</strong> - enable connections to a socket</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS listen    (    int s,      /* socket descriptor */    int backlog /* number of connections to queue */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine enables connections to a socket.  It also specifies themaximum number of unaccepted connections that can be pending at one time(<i>backlog</i>).  After enabling connections with <b><i><a href="./sockLib.html#listen">listen</a></i>(&nbsp;)</b>, connections areactually accepted by <b><i><a href="./sockLib.html#accept">accept</a></i>(&nbsp;)</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the socket is invalid or unable to listen.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b><hr><a name="accept"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>accept</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>accept</i>(&nbsp;)</strong> - accept a connection from a socket</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int accept    (    int               s,      /* socket descriptor */    struct sockaddr * addr,   /* peer address */    int *             addrlen /* peer address length */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine accepts a connection on a socket, and returns a new socketcreated for the connection.  The socket must be bound to an address with<b><i><a href="./sockLib.html#bind">bind</a></i>(&nbsp;)</b>, and enabled for connections by a call to <b><i><a href="./sockLib.html#listen">listen</a></i>(&nbsp;)</b>.  The <b><i><a href="./sockLib.html#accept">accept</a></i>(&nbsp;)</b>routine dequeues the first connection and creates a new socket with thesame properties as <i>s</i>.  It blocks the caller until a connection ispresent, unless the socket is marked as non-blocking.<p>The parameter <i>addrlen</i> should be initialized to the size of the availablebuffer pointed to by <i>addr</i>.  Upon return, <i>addrlen</i> contains the size inbytes of the peer's address stored in <i>addr</i>.<p></blockquote><h4>RETURNS</h4><blockquote><p>A socket descriptor, or ERROR if the call fails.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b><hr><a name="connect"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>connect</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>connect</i>(&nbsp;)</strong> - initiate a connection to a socket</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS connect    (    int               s,      /* socket descriptor */    struct sockaddr * name,   /* addr of socket to connect */    int               namelen /* length of name, in bytes */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>If <i>s</i> is a socket of type <b>SOCK_STREAM</b>, this routine establishes a virtualcircuit between <i>s</i> and another socket specified by <i>name</i>.  If <i>s</i> is oftype <b>SOCK_DGRAM</b>, it permanently specifies the peer to which messagesare sent.  If <i>s</i> is of type <b>SOCK_RAW</b>, it specifies the raw socket uponwhich data is to be sent and received.  The <i>name</i> parameter specifies theaddress of the other socket.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the call fails.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b><hr><a name="connectWithTimeout"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>connectWithTimeout</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>connectWithTimeout</i>(&nbsp;)</strong> - try to connect over a socket for a specified duration</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS connectWithTimeout    (    int               sock,    /* socket descriptor */    struct sockaddr * adrs,    /* addr of the socket to connect */    int               adrsLen, /* length of the socket, in bytes */    struct timeval *  timeVal  /* time-out value */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine basically the same as <b><i><a href="./sockLib.html#connect">connect</a></i>(&nbsp;)</b>, except that it lets users specify how long to keep trying to make the new connection.<p>If the <i>timeVal</i> is a NULL pointer, this routine acts exactly like<b><i><a href="./sockLib.html#connect">connect</a></i>(&nbsp;)</b>.  If <i>timeVal</i> is not NULL, it tries to establish a newconnection for the duration of the time specified in <i>timeVal</i>. Afterthat time, this routine reports a time-out error if the connection is notestablished.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if a connection cannot be established.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b>, <b><i><a href="./sockLib.html#connect">connect</a></i>(&nbsp;)</b><hr><a name="sendto"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>sendto</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>sendto</i>(&nbsp;)</strong> - send a message to a socket</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int sendto    (    int               s,      /* socket to send data to */    caddr_t           buf,    /* pointer to data buffer */    int               bufLen, /* length of buffer */    int               flags,  /* flags to underlying protocols */    struct sockaddr * to,     /* recipient's address */    int               tolen   /* length of <i>to</i> sockaddr */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sends a message to the datagram socket named by <i>to</i>.  Thesocket <i>s</i> is received by the receiver as the sending socket.<p>The maximum length of <i>buf</i> is subject to the limits on UDP buffersize. See the discussion of <b>SO_SNDBUF</b> in the <b><i><a href="./sockLib.html#setsockopt">setsockopt</a></i>(&nbsp;)</b> manualentry.<p>You can OR the following values into the <i>flags</i> parameter with thisoperation:<p><dl><dt><b>MSG_OOB</b> (0x1)<dd>Out-of-band data.<p><dt><b>MSG_DONTROUTE</b> (0x4)<dd> Send without using routing tables. </dl><p></blockquote><h4>RETURNS</h4><blockquote><p>The number of bytes sent, or ERROR if the call fails.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./sockLib.html#top">sockLib</a></b>, <b><i><a href="./sockLib.html#setsockopt">setsockopt</a></i>(&nbsp;)</b><hr>

⌨️ 快捷键说明

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