mirror of
https://github.com/nasa/trick.git
synced 2025-01-18 18:56:31 +00:00
parent
69d64fb582
commit
c1aff35a6a
@ -3,6 +3,8 @@
|
|||||||
* Establish a connection with a communications server
|
* Establish a connection with a communications server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -86,7 +88,7 @@ int tc_connect_(TCDevice * device, const char *file, int line)
|
|||||||
the_socket = socket( TRICKCOMM_SOCKET_FAMILY, SOCK_STREAM, TRICKCOMM_SOCKET_PROTO );
|
the_socket = socket( TRICKCOMM_SOCKET_FAMILY, SOCK_STREAM, TRICKCOMM_SOCKET_PROTO );
|
||||||
if ( the_socket == TRICKCOMM_INVALID_SOCKET){
|
if ( the_socket == TRICKCOMM_INVALID_SOCKET){
|
||||||
|
|
||||||
trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not open socket\n", client_str);
|
trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not open socket: %s\n", client_str, strerror(errno));
|
||||||
|
|
||||||
return (TC_COULD_NOT_OPEN_SOCKET);
|
return (TC_COULD_NOT_OPEN_SOCKET);
|
||||||
}
|
}
|
||||||
@ -141,7 +143,7 @@ int tc_connect_(TCDevice * device, const char *file, int line)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( ret < 0) {
|
if ( ret < 0) {
|
||||||
trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not connect to host\n", client_str);
|
trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not connect to host: %s\n", client_str, strerror(errno));
|
||||||
CLOSE_SOCKET(the_socket);
|
CLOSE_SOCKET(the_socket);
|
||||||
return (TC_COULD_NOT_CONNECT);
|
return (TC_COULD_NOT_CONNECT);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
* Set up a device on which to listen for connections
|
* Set up a device on which to listen for connections
|
||||||
*/
|
*/
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
@ -61,7 +63,7 @@ int tc_init_with_connection_info( TCDevice * listen_device,
|
|||||||
if (listen_socket == TRICKCOMM_INVALID_SOCKET) {
|
if (listen_socket == TRICKCOMM_INVALID_SOCKET) {
|
||||||
trick_error_report(listen_device->error_handler,
|
trick_error_report(listen_device->error_handler,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__,
|
TRICK_ERROR_ALERT, __FILE__, __LINE__,
|
||||||
"could not open socket on port %d\n", (listen_device->port));
|
"could not open socket on port %d: %s\n", listen_device->port, strerror(errno));
|
||||||
return (TC_COULD_NOT_OPEN_SOCKET);
|
return (TC_COULD_NOT_OPEN_SOCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +107,7 @@ int tc_init_with_connection_info( TCDevice * listen_device,
|
|||||||
if (bind(listen_socket, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) {
|
if (bind(listen_socket, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) {
|
||||||
trick_error_report(listen_device->error_handler,
|
trick_error_report(listen_device->error_handler,
|
||||||
TRICK_ERROR_ADVISORY, __FILE__, __LINE__,
|
TRICK_ERROR_ADVISORY, __FILE__, __LINE__,
|
||||||
"could not bind socket for port %d\n", (listen_device->port));
|
"could not bind socket for port %d: %s\n", listen_device->port, strerror(errno));
|
||||||
return (TC_COULD_NOT_BIND_SOCKET);
|
return (TC_COULD_NOT_BIND_SOCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +124,7 @@ int tc_init_with_connection_info( TCDevice * listen_device,
|
|||||||
/* listen can get EADDRINUSE when server & client are same machine */
|
/* listen can get EADDRINUSE when server & client are same machine */
|
||||||
trick_error_report(listen_device->error_handler,
|
trick_error_report(listen_device->error_handler,
|
||||||
TRICK_ERROR_ADVISORY, __FILE__, __LINE__,
|
TRICK_ERROR_ADVISORY, __FILE__, __LINE__,
|
||||||
"could not listen on port %d\n", (listen_device->port));
|
"could not listen on port %d: %s\n", listen_device->port, strerror(errno));
|
||||||
return (TC_COULD_NOT_LISTEN_SOCKET);
|
return (TC_COULD_NOT_LISTEN_SOCKET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user