if (!nego_connect(rdp->nego))
{
if (!freerdp_get_last_error(rdp->context))
+ {
freerdp_set_last_error(rdp->context, FREERDP_ERROR_SECURITY_NEGO_CONNECT_FAILED);
- WLog_ERR(TAG, "Error: protocol security negotiation or connection failure");
+ WLog_ERR(TAG, "Error: protocol security negotiation or connection failure");
+ }
return FALSE;
}
BOOL useExternalDefinedSocket = FALSE;
if (!hostname)
+ {
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
return -1;
+ }
if (hostname[0] == '/')
ipcSocket = TRUE;
sockfd = freerdp_uds_connect(hostname);
if (sockfd < 0)
+ {
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
return -1;
+ }
}
else if (useExternalDefinedSocket)
sockfd = port;
if (sockfd < 0)
{
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
freeaddrinfo(result);
return -1;
}
{
freeaddrinfo(result);
close(sockfd);
+
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
WLog_ERR(TAG, "failed to connect to %s", hostname);
return -1;
}
if (!useExternalDefinedSocket)
close(sockfd);
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
WLog_ERR(TAG, "Couldn't get socket ip address");
return -1;
}
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (void*) &optval, optlen) < 0)
{
close(sockfd);
+
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
WLog_ERR(TAG, "unable to set receive buffer len");
return -1;
}
if (!freerdp_tcp_set_keep_alive_mode(sockfd))
{
close(sockfd);
+
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_FAILED);
+
WLog_ERR(TAG, "Couldn't set keep alive mode.");
return -1;
}
if (WaitForSingleObject(context->abortEvent, 0) == WAIT_OBJECT_0)
{
close(sockfd);
+
+ if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS)
+ freerdp_set_last_error(context, FREERDP_ERROR_CONNECT_CANCELLED);
+
return -1;
}