Fresh IDE . Artifact [012e728c65]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Artifact 012e728c6520386fb9ce9ce4a8e3651da361f106:


 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
.style3 {color: #660000}
-->
</style></head>
<body style="margin:0px 0px 0px 0px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">SYS_SOCKET</span></td>
  </tr>
  <tr>
    <td><p style="margin-left:22px;margin-top:0px"><br />
      Create an endpoint for communication. </p>
      <p style="margin-left:10px"><strong>Arguments:</strong></p>
      <table width="100%" border="0" style="margin-left:20px; margin-right:20px">
        <tr>
          <td width="6%" valign="top"><code><em>1st </em></code></td>
          <td width="94%">Protocol family which will be used for communication. The  currently understood formats include: <span class="style3">*should add more* </span>
            <table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333">
              <tr>
                <td><table width="100%" border="0">
                    <tr>
                      <td width="13%" valign="top"><code>PF_UNIX,&nbsp;<br />
                      PF_LOCAL</code></td>
                      <td width="87%" valign="top"><code>Local communication.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_INET </code></td>
                      <td valign="top"><code>IPv4 Internet protocols.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_INET6 </code></td>
                      <td valign="top"><code>IPv6 Internet protocols.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_IPX</code></td>
                      <td valign="top"><code>IPX - Novell protocols.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_NETLINK </code></td>
                      <td valign="top"><code>Kernel user interface device.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_X25 </code></td>
                      <td valign="top"><code>ITU-T X.25 / ISO-8208 protocol.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_AX25 </code></td>
                      <td valign="top"><code>Amateur radio AX.25 protocol. </code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_ATMPVC </code></td>
                      <td valign="top"><code>Access to raw ATM PVCs.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_APPLETALK </code></td>
                      <td valign="top"><code>Appletalk.</code></td>
                    </tr>
                    <tr>
                      <td valign="top"><code>PF_PACKET </code></td>
                      <td valign="top"><code>Low level packet interface.</code></td>
                    </tr>
                </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td valign="top"><code><em>2nd</em></code></td>
          <td>Communication semantics. Currently defined types are: 
            <table width="100%" border="0">
              <tr>
                <td width="14%" valign="top"><code>SOCK_STREAM</code></td>
                <td width="86%"><code>Provides sequenced, reliable, two-way, connection-based byte streams. An  out-of-band data transmission mechanism may be supported. <br />  
                  <br />
                  Such sockets types are full-duplex byte streams, similar to  pipes. They do not preserve record boundaries. A stream socket must be in a connected state before any data may be sent or received on it. A  connection to another socket is created with a <a href="sys_connect.html">SYS_CONNECT</a> call. Once connected, data may  be transferred using <a href="3.html">sys_read</a> and <a href="4.html">sys_write</a> calls or some variant of the <a href="sys_send.html">SYS_SEND</a> and <a href="sys_recv.html">SYS_RECV</a> calls. When a session has been  completed a <a href="6.html">sys_close</a> may be performed.<br />  
                  <br />    
                The communications protocols which implement a SOCK_STREAM ensure that  data is not lost or duplicated. If a piece of data for which the peer protocol  has buffer space cannot be successfully transmitted within a reasonable length  of time, then the connection is considered to be dead. When SO_KEEPALIVE is enabled on the socket the protocol checks in a protocol-specific manner  if the other end is still alive. A SIGPIPE signal is raised if a process  sends or receives on a broken stream; this causes naive processes, which do not  handle the signal, to exit.</code></td>
              </tr>
              <tr>
                <td valign="top"><code>SOCK_DGRAM</code></td>
                <td><code>Supports datagrams (connectionless, unreliable messages of a fixed maximum  length).<br />
                  Datagrams are sent to correspondents named in <a href="sys_sendto.html">SYS_SENDTO</a> calls. Datagrams are generally  received with <a href="sys_recvfrom.html">SYS_RECVFROM</a>, which  returns the next datagram along with the address of its sender. </code>               </td>
              </tr>
              <tr>
                <td valign="top"><code>SOCK_RAW</code></td>
                <td><code>Provides raw network protocol access and allows sending of datagrams to correspondents named in <a href="sys_sendto.html">SYS_SENDTO</a> calls. Datagrams are generally  received with <a href="sys_recvfrom.html">SYS_RECVFROM</a>, which  returns the next datagram along with the address of its sender. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>SOCK_RDM</code></td>
                <td><code>Provides a reliable datagram layer that does not guarantee ordering. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>SOCK_SEQPACKET</code></td>
                <td><code>Provides a sequenced, reliable, two-way connection-based data transmission path  for datagrams of fixed maximum length; a consumer is required to read an entire  packet with each read system call. <br />  
                  <br />      
                SOCK_SEQPACKET sockets employ the same system calls as SOCK_STREAM sockets. The only difference is that <a href="3.html">sys_read</a> calls will return only the amount of  data requested, and any data remaining in the arriving packet will be discarded.  Also all message boundaries in incoming datagrams are preserved. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>SOCK_DCCP</code></td>
                <td><code><span class="style3">*to be documented* </span></code></td>
              </tr>
              <tr>
                <td valign="top"><code>SOCK_PACKET</code></td>
                <td><code>Obsolete and should not be used in new programs; see <em>man 7 packet</em>. <br />
                SCOK_PACKET allowed to receive raw packets directly from the device  driver. </code></td>
              </tr>
            </table>
          <br />
          Some socket types may not be implemented by all protocol families; for example,  SOCK_SEQPACKET is not implemented for AF_INET.</td>
        </tr>
        <tr>
          <td valign="top"><code><em>3rd</em></code></td>
          <td>Protocol to be used with the socket.          <br />
          Normally only a single protocol exists to support a particular socket type  within a given protocol family, in which case this argument  can be specified  as 0. However, it is possible that many protocols may exist, in which case a  particular protocol must be specified in this manner. The protocol number to use  is specific to the &quot;communication domain&quot; in which communication is to take  place. See /etc/protocols for a list of available protocols. </td>
        </tr>
      </table>
      <p style="margin-left:10px" ><strong>Return values</strong></p>
      <p style="margin-left:22px;margin-right:10px" >If the system call succeeds the return value is a file descriptor for the new socket.<br />
If the system call fails the return value is one of the following <em>errno</em> values (other errors may be generated by the underlying protocol modules.):</p>
      <table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333;margin-left:22px;margin-right:22px">
        <tr>
          <td><table width="100%" border="0">
              <tr>
                <td width="10%" valign="top"><code>-EACCES </code></td>
                <td width="90%" valign="top"><code>Permission to create a socket of the specified type and/or protocol is denied. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EAFNOSUPPORT </code></td>
                <td valign="top"><code>The implementation does not support the specified address family. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EINVAL </code></td>
                <td valign="top"><code>Unknown protocol, or protocol family not available. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EMFILE </code></td>
                <td valign="top"><code>Process file table overflow. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-ENFILE </code></td>
                <td valign="top"><code>The system limit on the total number of open files has been reached. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-ENOBUFS,<br />
                -ENOMEM </code></td>
                <td valign="top"><code>Insufficient memory is available. The socket cannot be created until sufficient  resources are freed. </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EPROTONOSUPPORT </code></td>
                <td valign="top"><code>The protocol type or the specified protocol is not supported within this domain. </code></td>
              </tr>
          </table></td>
        </tr>
      </table>
      <p style="margin-left:10px"><strong>Remarks</strong></p>
      <p style="margin-left:22px">An <a href="55.html">sys_fcntl</a> F_SETOWN operation can be used to specify a process or process group to receive a SIGURG signal when the out-of-band data arrives or SIGPIPE signal  when a SOCK_STREAM connection breaks unexpectedly. This operation may  also be used to set the process or process group that receives the I/O and  asynchronous notification of I/O events via SIGIO. Using F_SETOWN is equivalent to an <a href="54.html">sys_ioctl</a> call with  the FIOSETOWN or SIOCSPGRP argument.<br />
        <br />
      When the network signals an error condition to the protocol module (e.g.,  using a ICMP message for IP) the pending error flag is set for the socket. The  next operation on this socket will return the error code of the pending error.  For some protocols it is possible to enable a per-socket error queue to retrieve  detailed information about the error; see IP_RECVERR in <em>man 7 ip</em><strong>.</strong> <br>
      <br>
      See /samples/basic/socket/icmp.asm for an example. </p>
      <p style="margin-left:10px"><strong>Compatibility</strong></p>
    <p style="margin-left:22px">n/a</p></td>
  </tr>
</table></body></html>