|
|
@ -81,7 +81,7 @@ This function also needs more testing for TCP. */
|
|
|
|
char* Sock::recvAll() {
|
|
|
|
char* Sock::recvAll() {
|
|
|
|
int num_bytes_received = 0;
|
|
|
|
int num_bytes_received = 0;
|
|
|
|
int total_bytes_received = 0;
|
|
|
|
int total_bytes_received = 0;
|
|
|
|
char* buffer = (char *)malloc(100);
|
|
|
|
char* buffer = (char *)malloc(150);
|
|
|
|
bool has_been_read = false;
|
|
|
|
bool has_been_read = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (this->protocol == ES_UDP) {
|
|
|
|
if (this->protocol == ES_UDP) {
|
|
|
@ -117,7 +117,8 @@ char* Sock::recvAll() {
|
|
|
|
return buffer;
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Non-blocking recv call - Uses 'select' to poll for data from the FD. */
|
|
|
|
/* Non-blocking recv call - Uses 'select' to poll for data from the FD. Returns an empty string if there
|
|
|
|
|
|
|
|
is nothing to read. */
|
|
|
|
char* Sock::recvAllNB() {
|
|
|
|
char* Sock::recvAllNB() {
|
|
|
|
struct timeval tv;
|
|
|
|
struct timeval tv;
|
|
|
|
fd_set readfs;
|
|
|
|
fd_set readfs;
|
|
|
@ -131,7 +132,7 @@ char* Sock::recvAllNB() {
|
|
|
|
if (FD_ISSET(this->sock_fd, &readfs)) {
|
|
|
|
if (FD_ISSET(this->sock_fd, &readfs)) {
|
|
|
|
return Sock::recvAll();
|
|
|
|
return Sock::recvAll();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
return (char *)"";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|