]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/BsdSocketLib/connect.c
StdLib: Move GetPass.c out of Uefi and into PosixLib. Create LibPosix to contain...
[mirror_edk2.git] / StdLib / BsdSocketLib / connect.c
index 92fc75bdb0ed593ad62440ad8b6f19b6ad3a91a6..aa4df57d9f435c42ab941c96c79ab80e206a940a 100644 (file)
 /**\r
   Connect to a remote system via the network.\r
 \r
-  The ::connect routine attempts to establish a connection to a\r
+  The connect routine attempts to establish a connection to a\r
   socket on the local or remote system using the specified address.\r
-  The\r
-  <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">POSIX</a>\r
-  documentation is available online.\r
 \r
   There are three states associated with a connection:\r
   <ul>\r
     <li>Connection in progress</li>\r
     <li>Connected</li>\r
   </ul>\r
-  In the "Not connected" state, calls to ::connect start the connection\r
+  In the initial "Not connected" state, calls to connect start the connection\r
   processing and update the state to "Connection in progress".  During\r
   the "Connection in progress" state, connect polls for connection completion\r
   and moves the state to "Connected" after the connection is established.\r
   Note that these states are only visible when the file descriptor is marked\r
-  with O_NONBLOCK.  Also, the POLL_WRITE bit is set when the connection\r
+  with O_NONBLOCK.  Also, the POLLOUT bit is set when the connection\r
   completes and may be used by poll or select as an indicator to call\r
   connect again.\r
 \r
+  The\r
+  <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">POSIX</a>\r
+  documentation is available online.\r
+  \r
   @param [in] s         Socket file descriptor returned from ::socket.\r
 \r
   @param [in] address   Network address of the remote system\r
 \r
   @param [in] address_len Length of the remote network address\r
 \r
-  @return     ::connect returns zero if successful and -1 when an error occurs.\r
-              In the case of an error, errno contains more details.\r
+  @return     This routine returns zero if successful and -1 when an error occurs.\r
+              In the case of an error, ::errno contains more details.\r
 \r
  **/\r
 int\r
@@ -70,9 +71,9 @@ connect (
                                             &errno );\r
   if ( NULL != pSocketProtocol ) {\r
     //\r
-    // TODO: Check for NON_BLOCKING\r
+    //  Determine if the operation is blocking\r
     //\r
-    bBlocking = TRUE;\r
+    bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));\r
 \r
     //\r
     //  Attempt to connect to a remote system\r