Initial commit of files
This commit is contained in:
25
src/libnet/tcp_recv.c
Normal file
25
src/libnet/tcp_recv.c
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// TCP recv
|
||||
//
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
int tcp_recv( int sock, void *buf, int len )
|
||||
{
|
||||
char *s = (char *)buf;
|
||||
size_t n;
|
||||
|
||||
/* check! */
|
||||
if ( sock < 0 )
|
||||
return -1;
|
||||
if ( !buf || len <= 0 )
|
||||
return -1;
|
||||
|
||||
/* read */
|
||||
n = recv( sock, buf, len, 0 );
|
||||
|
||||
if ( n > 0 )
|
||||
*(s+n) = '\0';
|
||||
|
||||
return n;
|
||||
}
|
||||
Reference in New Issue
Block a user