summaryrefslogtreecommitdiff
path: root/StdLib/BsdSocketLib/sendto.c
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 23:02:35 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 23:02:35 +0000
commita88c31639bb24c73383a4528a5b77066e805148b (patch)
tree058801cd8687b0a0c6f82459b56b2ad3beb43bf4 /StdLib/BsdSocketLib/sendto.c
parentdf7499fcc1fbd6c825cabf19bbed379688416125 (diff)
downloadedk2-platforms-a88c31639bb24c73383a4528a5b77066e805148b.tar.xz
Update the sockets library code
* Passes conformance and functional tests. * Builds with GCC 4.4 compiler. Signed-off by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12497 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib/BsdSocketLib/sendto.c')
-rw-r--r--StdLib/BsdSocketLib/sendto.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/StdLib/BsdSocketLib/sendto.c b/StdLib/BsdSocketLib/sendto.c
index 5311ce6022..2fb7737c30 100644
--- a/StdLib/BsdSocketLib/sendto.c
+++ b/StdLib/BsdSocketLib/sendto.c
@@ -18,7 +18,11 @@
/**
Send data using a network connection.
- The ::send routine queues data to the network for transmission.
+ The sendto routine queues data to the network for transmission.
+ This routine is typically used for SOCK_DGRAM sockets that are shared
+ between multiple machine where it is required to specify the target
+ system address when sending the data.
+
The
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">POSIX</a>
documentation is available online.
@@ -35,9 +39,9 @@
@param [in] tolen Length of remote system address structure
- @return ::send returns the number of data bytes that were
+ @return This routine returns the number of data bytes that were
sent and -1 when an error occurs. In the case of
- an error, errno contains more details.
+ an error, ::errno contains more details.
**/
ssize_t
@@ -50,6 +54,7 @@ sendto (
socklen_t tolen
)
{
+ BOOLEAN bBlocking;
ssize_t LengthInBytes;
CONST UINT8 * pData;
struct __filedes * pDescriptor;
@@ -69,19 +74,24 @@ sendto (
&errno );
if ( NULL != pSocketProtocol ) {
//
+ // Determine if the operation is blocking
+ //
+ bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
+
+ //
// Send the data using the socket
//
pData = buffer;
do {
errno = 0;
- Status = pSocketProtocol->pfnSend ( pSocketProtocol,
- flags,
- length,
- pData,
- (size_t *)&LengthInBytes,
- to,
- tolen,
- &errno );
+ Status = pSocketProtocol->pfnTransmit ( pSocketProtocol,
+ flags,
+ length,
+ pData,
+ (size_t *)&LengthInBytes,
+ to,
+ tolen,
+ &errno );
if ( EFI_ERROR ( Status ) && ( EFI_NOT_READY != Status )) {
LengthInBytes = -1;
break;
@@ -92,8 +102,7 @@ sendto (
//
pData += LengthInBytes;
length -= LengthInBytes;
- // TODO: Add non-blocking check
- } while (( 0 != length ) && ( EFI_NOT_READY == Status ));
+ } while (( 0 != length ) && ( EFI_NOT_READY == Status ) && bBlocking );
}
//