Added NoRouteToHost error. Fixed Disconnect not being returned by Socket
This commit is contained in:
parent
d53cc86fb9
commit
992fbc885e
@ -39,6 +39,7 @@ namespace fr
|
||||
ReceiveError = 17,
|
||||
AcceptError = 18,
|
||||
SSLError = 19,
|
||||
NoRouteToHost = 20
|
||||
//Remember to update status_to_string if more are added
|
||||
};
|
||||
|
||||
|
||||
@ -70,7 +70,11 @@ namespace fr
|
||||
if(receive_timeout == 0)
|
||||
{
|
||||
status = mbedtls_ssl_read(ssl.get(), (unsigned char *)data, data_size);
|
||||
if(status <= 0)
|
||||
if(status == 0)
|
||||
{
|
||||
return Socket::Status::Disconnected;
|
||||
}
|
||||
if(status < 0)
|
||||
{
|
||||
if(status == MBEDTLS_ERR_SSL_WANT_READ || status == MBEDTLS_ERR_SSL_WANT_WRITE)
|
||||
{
|
||||
|
||||
@ -156,6 +156,9 @@ namespace fr
|
||||
return "Generic SSL Error";
|
||||
#endif
|
||||
}
|
||||
case NoRouteToHost:
|
||||
return "No Route To Host";
|
||||
break;
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
@ -52,11 +52,17 @@ namespace fr
|
||||
|
||||
Socket::Status TcpSocket::receive_raw(void *data, size_t buffer_size, size_t &received)
|
||||
{
|
||||
received = 0;
|
||||
ssize_t status = 0;
|
||||
do
|
||||
{
|
||||
status = ::recv(socket_descriptor, (char*)data, buffer_size, 0);
|
||||
if(status <= 0)
|
||||
if(status == 0)
|
||||
{
|
||||
return Socket::Status::Disconnected;
|
||||
}
|
||||
|
||||
if(status < 0)
|
||||
{
|
||||
if(errno == EWOULDBLOCK || errno == EAGAIN)
|
||||
{
|
||||
@ -163,7 +169,7 @@ namespace fr
|
||||
//We're done with this now, cleanup
|
||||
freeaddrinfo(info);
|
||||
if(c == nullptr)
|
||||
return Socket::Status::Error;
|
||||
return Socket::Status::NoRouteToHost;
|
||||
|
||||
//Turn back to blocking mode
|
||||
if(!set_unix_socket_blocking(socket_descriptor, false, true))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user