|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflsock.h"
int
connect_to_peer (
sock_t handle, /* Socket to connect */
const struct sockaddr_in *sin /* Socket address structure */
)
Connects an unconnected TCP or UDP socket to a peer specified by a sockaddr structure. Returns 0 if the connection succeeded, or SOCKET_ERROR if there was a problem. In the latter case you can get the reason for the error by calling sockmsg().
{
#if (defined (DOES_SOCKETS))
int
rc; /* Return code from call */
Bool
old_nonblock; /* Create non-blocking sockets */
ASSERT (sin);
old_nonblock = ip_nonblock;
# if (defined (BLOCKING_CONNECT))
ip_nonblock = FALSE; /* Block on this socket */
# endif
rc = connect ((SOCKET) handle, (struct sockaddr *) sin, sizeof (*sin));
ip_nonblock = old_nonblock;
prepare_socket (handle); /* Set final blocking mode */
# if (defined (__WINDOWS__))
return (win_error (rc));
# else
return (rc);
# endif
#else
connect_error_value = IP_NOSOCKETS;
return ((int) SOCKET_ERROR); /* Sockets not supported */
#endif
}
| | << | < | > | >> |
|