Navigation


Changeset 24:bd83ce9328ed in freeDiameter for freeDiameter/tcp.c


Ignore:
Timestamp:
Oct 21, 2009, 6:42:45 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Cleanups and completed sctp code (not finished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/tcp.c

    r23 r24  
    113113}
    114114
     115/* Create a client socket and connect to remote server */
     116int fd_tcp_client( int *sock, sSA * sa, socklen_t salen )
     117{
     118        TRACE_ENTRY("%p %p %d", sock, sa, salen);
     119        CHECK_PARAMS( sock && sa && salen );
     120       
     121        /* Create the socket */
     122        CHECK_SYS(  *sock = socket(sa->sa_family, SOCK_STREAM, IPPROTO_TCP)  );
     123       
     124        /* Cleanup if we are cancelled */
     125        pthread_cleanup_push(fd_cleanup_socket, sock);
     126       
     127        /* Set the socket options */
     128        CHECK_FCT(  fd_tcp_setsockopt(sa->sa_family, *sock)  );
     129       
     130        TRACE_DEBUG_sSA(FULL, "Attempting TCP connection with peer: ", sa, NI_NUMERICHOST | NI_NUMERICSERV, "..." );
     131       
     132        /* Try connecting to the remote address */
     133        CHECK_SYS( connect(*sock, sa, salen) );
     134       
     135        /* Done! */
     136        pthread_cleanup_pop(0);
     137        return 0;
     138}
     139
     140
    115141/* Get the local name of a TCP socket -- would be nice if it did not return "0.0.0.0"... */
    116142int fd_tcp_get_local_ep(int sock, sSS * ss, socklen_t *sl)
Note: See TracChangeset for help on using the changeset viewer.