]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/sendto.c
2 Implement the sendto API.
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <SocketInternals.h>
19 Send data using a network connection.
21 The ::send routine queues data to the network for transmission.
23 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">POSIX</a>
24 documentation is available online.
26 @param [in] s Socket file descriptor returned from ::socket.
28 @param [in] buffer Address of a buffer containing the data to send.
30 @param [in] length Length of the buffer in bytes.
32 @param [in] flags Message control flags
34 @param [in] to Remote system address
36 @param [in] tolen Length of remote system address structure
38 @return ::send returns the number of data bytes that were
39 sent and -1 when an error occurs. In the case of
40 an error, errno contains more details.
49 const struct sockaddr
* to
,
53 ssize_t LengthInBytes
;
55 struct __filedes
* pDescriptor
;
56 EFI_SOCKET_PROTOCOL
* pSocketProtocol
;
65 // Locate the context for this socket
67 pSocketProtocol
= BslFdToSocketProtocol ( s
,
70 if ( NULL
!= pSocketProtocol
) {
72 // Send the data using the socket
77 Status
= pSocketProtocol
->pfnSend ( pSocketProtocol
,
81 (size_t *)&LengthInBytes
,
85 if ( EFI_ERROR ( Status
) && ( EFI_NOT_READY
!= Status
)) {
91 // Account for the data sent
93 pData
+= LengthInBytes
;
94 length
-= LengthInBytes
;
95 // TODO: Add non-blocking check
96 } while (( 0 != length
) && ( EFI_NOT_READY
== Status
));
100 // Return the number of data bytes sent, -1 for errors
102 return (INT32
)LengthInBytes
;