]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/read.c
Update the sockets library code
[mirror_edk2.git] / StdLib / BsdSocketLib / read.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the read 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 Read support routine for sockets\r
20\r
a88c3163 21 The BslSocketRead routine is called indirectly by the read file\r
22 system routine. 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
d7ce7006 26 @param [in] pDescriptor Descriptor address for the file\r
27 @param [in] pOffset File offset\r
28 @param [in] LengthInBytes Number of bytes to read\r
29 @param [in] pBuffer Address of the buffer to receive the data\r
30\r
7dc13291 31 @return The number of bytes read or -1 if an error occurs.\r
a88c3163 32 In the case of an error, ::errno contains more details.\r
d7ce7006 33\r
34**/\r
35ssize_t\r
36BslSocketRead (\r
37 struct __filedes *pDescriptor,\r
38 off_t * pOffset,\r
39 size_t LengthInBytes,\r
40 void * pBuffer\r
41 )\r
42{\r
43 ssize_t BytesRead;\r
44\r
45 //\r
46 // Receive the data from the remote system\r
47 //\r
48 BytesRead = recvfrom ( pDescriptor->MyFD,\r
49 pBuffer,\r
50 LengthInBytes,\r
51 0,\r
52 NULL,\r
53 NULL );\r
54\r
55 //\r
56 // Return the number of bytes read\r
57 //\r
58 return BytesRead;\r
59}\r