]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/recv.c
Fix send to properly wait while long transmits are in progress
[mirror_edk2.git] / StdLib / BsdSocketLib / recv.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the recv API.\r
3\r
4 Copyright (c) 2011, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <SocketInternals.h>\r
16\r
17\r
18/**\r
19 Receive data from a network connection.\r
20\r
21 The ::recv routine waits for receive data from a remote network\r
22 connection. The\r
23 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">POSIX</a>\r
24 documentation is available online.\r
25\r
26 @param [in] s Socket file descriptor returned from ::socket.\r
27\r
28 @param [in] buffer Address of a buffer to receive the data.\r
29 \r
30 @param [in] length Length of the buffer in bytes.\r
31\r
32 @param [in] flags Message control flags\r
33\r
34 @returns ::recv returns the number of valid bytes in the buffer,\r
35 zero if no data was received, and -1 when an error occurs.\r
36 In the case of an error, errno contains more details.\r
37\r
38 **/\r
39ssize_t\r
40recv (\r
41 int s,\r
42 void * buffer,\r
43 size_t length,\r
44 int flags\r
45 )\r
46{\r
47 ssize_t BytesRead;\r
48 \r
49 //\r
50 // Receive the data from the remote system\r
51 //\r
52 BytesRead = recvfrom ( s,\r
53 buffer,\r
54 length,\r
55 flags,\r
56 NULL,\r
57 NULL );\r
58\r
59 //\r
60 // Return the number of bytes read\r
61 //\r
62 return BytesRead;\r
63}\r