1/** @file 2 Implement the recv API. 3 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 9 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. 12 13**/ 14 15#include <SocketInternals.h> 16 17 18/** 19 Receive data from a network connection. 20 21 The recv routine waits for receive data from a remote network 22 connection. This routine is typically used for SOCK_STREAM 23 because it waits for receive data from the target system specified 24 in the ::connect call. 25 26 The 27 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">POSIX</a> 28 documentation is available online. 29 30 @param [in] s Socket file descriptor returned from ::socket. 31 32 @param [in] buffer Address of a buffer to receive the data. 33 34 @param [in] length Length of the buffer in bytes. 35 36 @param [in] flags Message control flags 37 38 @return This routine returns the number of valid bytes in the buffer, 39 zero if no data was received, and -1 when an error occurs. 40 In the case of an error, ::errno contains more details. 41 42 **/ 43ssize_t 44recv ( 45 int s, 46 void * buffer, 47 size_t length, 48 int flags 49 ) 50{ 51 ssize_t BytesRead; 52 53 // 54 // Receive the data from the remote system 55 // 56 BytesRead = recvfrom ( s, 57 buffer, 58 length, 59 flags, 60 NULL, 61 NULL ); 62 63 // 64 // Return the number of bytes read 65 // 66 return BytesRead; 67} 68