added invalid socket check to read_socket function
This commit is contained in:
parent
b52f86a9a6
commit
72305929b2
@ -52,6 +52,8 @@ int main(void)
|
||||
|
||||
received = read_socket(accepted);
|
||||
|
||||
if (received == NULL) continue; //FAILED
|
||||
|
||||
printf("Received:\n%s\n\n", received);
|
||||
|
||||
why2_deallocate(received);
|
||||
@ -65,6 +67,12 @@ int main(void)
|
||||
|
||||
char *read_socket(int socket)
|
||||
{
|
||||
if (socket == -1)
|
||||
{
|
||||
fprintf(stderr, "Reading socket failed.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
long content_size = 0;
|
||||
char *content = NULL;
|
||||
|
||||
@ -78,4 +86,4 @@ char *read_socket(int socket)
|
||||
if (recv(socket, content, content_size, 0) != content_size) why2_die("Reading socket failed!");
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user