|
@ -419,7 +419,11 @@ Socket* POSIXSocket::Accept() const { |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int socket = accept(socket_, NULL, NULL); |
|
|
int socket; |
|
|
|
|
|
do |
|
|
|
|
|
socket = accept(socket_, NULL, NULL); |
|
|
|
|
|
while (socket == -1 && errno == EINTR); |
|
|
|
|
|
|
|
|
if (socket == -1) { |
|
|
if (socket == -1) { |
|
|
return NULL; |
|
|
return NULL; |
|
|
} else { |
|
|
} else { |
|
@ -446,7 +450,10 @@ bool POSIXSocket::Connect(const char* host, const char* port) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Connect.
|
|
|
// Connect.
|
|
|
status = connect(socket_, result->ai_addr, result->ai_addrlen); |
|
|
do |
|
|
|
|
|
status = connect(socket_, result->ai_addr, result->ai_addrlen); |
|
|
|
|
|
while (status == -1 && errno == EINTR); |
|
|
|
|
|
|
|
|
freeaddrinfo(result); |
|
|
freeaddrinfo(result); |
|
|
return status == 0; |
|
|
return status == 0; |
|
|
} |
|
|
} |
|
@ -465,13 +472,23 @@ bool POSIXSocket::Shutdown() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int POSIXSocket::Send(const char* data, int len) const { |
|
|
int POSIXSocket::Send(const char* data, int len) const { |
|
|
int status = send(socket_, data, len, 0); |
|
|
int status; |
|
|
|
|
|
|
|
|
|
|
|
do |
|
|
|
|
|
status = send(socket_, data, len, 0); |
|
|
|
|
|
while (status == -1 && errno == EINTR); |
|
|
|
|
|
|
|
|
return status; |
|
|
return status; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int POSIXSocket::Receive(char* data, int len) const { |
|
|
int POSIXSocket::Receive(char* data, int len) const { |
|
|
int status = recv(socket_, data, len, 0); |
|
|
int status; |
|
|
|
|
|
|
|
|
|
|
|
do |
|
|
|
|
|
status = recv(socket_, data, len, 0); |
|
|
|
|
|
while (status == -1 && errno == EINTR); |
|
|
|
|
|
|
|
|
return status; |
|
|
return status; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|