library/src/network/BP-Network.cc
// Reads A Specified Number Of Bytes From A Socket
Reads A Specified Number Of Bytes From A Socket
Reads A Specified Number Of Bytes From A Socket
int BP_NetRecv(P_BP_NETWORK_HANDLE net_handle, char * data, int size)
{
	if(!net_handle)
		return -1;
	if(!net_handle->sock)
		return -1;
	if(!data || !size)
		return -1;
	int readBytes = 0;
	net_handle->last_recv_counter = 0;
	readBytes = recv(net_handle->sock, data, size, 0);
	if(readBytes <= 0)
		return -1;
	net_handle->last_recv_counter = readBytes;
	net_handle->total_all_recv_counter += readBytes;
	net_handle->total_tcp_recv_counter += readBytes;
	return readBytes;
}
int BP_NetRecv ( P_BP_NETWORK_HANDLE net_handle , char * data , int size ) { if ( ! net_handle ) return -1 ; if ( ! net_handle -> sock ) return -1 ; if ( ! data || ! size ) return -1 ; int readBytes = 0 ; net_handle -> last_recv_counter = 0 ; readBytes = recv ( net_handle -> sock , data , size , 0 ) ; if ( readBytes <= 0 ) return -1 ; net_handle -> last_recv_counter = readBytes ; net_handle -> total_all_recv_counter += readBytes ; net_handle -> total_tcp_recv_counter += readBytes ; return readBytes ; }
Reads A Specified Number Of Bytes From A Socket
Reads A Specified Number Of Bytes From A Socket
// ensure we have a network handle // ensure we have a socket // ensure that we have data to send, and a valid positive size // create and initialize var to hold read bytes // reset last recv counter before doing anything // attempt to read data // return error if the read bytes are wrong // set the last recv counter // increment the total recv counter // increment the tcp recv counter // return the postiive value representing bytes read