]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/recv.c
Fix a bug about the iSCSI DHCP dependency issue.
[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
a88c3163 21 The recv routine waits for receive data from a remote network\r
22 connection. This routine is typically used for SOCK_STREAM\r
23 because it waits for receive data from the target system specified\r
24 in the ::connect call.\r
25\r
26 The\r
d7ce7006 27 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">POSIX</a>\r
28 documentation is available online.\r
29\r
30 @param [in] s Socket file descriptor returned from ::socket.\r
31\r
32 @param [in] buffer Address of a buffer to receive the data.\r
7dc13291 33\r
d7ce7006 34 @param [in] length Length of the buffer in bytes.\r
35\r
36 @param [in] flags Message control flags\r
37\r
a88c3163 38 @return This routine returns the number of valid bytes in the buffer,\r
d7ce7006 39 zero if no data was received, and -1 when an error occurs.\r
a88c3163 40 In the case of an error, ::errno contains more details.\r
d7ce7006 41\r
42 **/\r
43ssize_t\r
44recv (\r
45 int s,\r
46 void * buffer,\r
47 size_t length,\r
48 int flags\r
49 )\r
50{\r
51 ssize_t BytesRead;\r
7dc13291 52\r
d7ce7006 53 //\r
54 // Receive the data from the remote system\r
55 //\r
56 BytesRead = recvfrom ( s,\r
57 buffer,\r
58 length,\r
59 flags,\r
60 NULL,\r
61 NULL );\r
62\r
63 //\r
64 // Return the number of bytes read\r
65 //\r
66 return BytesRead;\r
67}\r