STCP/mysock_api.c
int myconnect(mysocket_t sd, struct sockaddr *name, int namelen)
{
    mysock_context_t *ctx = _mysock_get_context(sd);

    MYSOCK_CHECK(ctx != NULL, EINVAL);
    MYSOCK_CHECK((ctx->network_state.peer_addr_len == 0), EISCONN);

#ifdef DEBUG
    struct sockaddr_in *sin = (struct sockaddr_in *) name;
    fprintf(stderr, "\n####Initiating a new connection to %s:%u#### (sd=%d)\n",
            inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), sd);
    fflush(stderr);
#endif  /*DEBUG*/

    ctx->network_state.peer_addr       = *name;
    ctx->network_state.peer_addr_len   = namelen;
    ctx->network_state.peer_addr_valid = TRUE;

    /* record connection setup for demultiplexing */
    if (!ctx->bound)
    {
        int rc;

        /* we need to find the local port number to set up demultiplexing
         * before we send the SYN.  (this is really only required in the VNS
         * case--we have to demultiplex only on listening sockets for the
         * UDP/TCP network layer--but it doesn't do any harm here in
         * general).
         */
        if ((rc = _mysock_bind_ephemeral(ctx)) < 0)
            return rc;
    }

    /* time for kick off */
    _mysock_transport_init(sd, TRUE);

    /* block until connection is established, or we hit an error */
    return _mysock_wait_for_connection(ctx);
}
/* connect to the address specified in name on the mysocket sd */
connect to the address specified in name on the mysocket sd
connect to the address specified in name on the mysocket sd
int myconnect(mysocket_t sd, struct sockaddr *name, int namelen)
{
    mysock_context_t *ctx = _mysock_get_context(sd);
    MYSOCK_CHECK(ctx != NULL, EINVAL);
    MYSOCK_CHECK((ctx->network_state.peer_addr_len == 0), EISCONN);
#ifdef DEBUG
    struct sockaddr_in *sin = (struct sockaddr_in *) name;
    fprintf(stderr, "\n####Initiating a new connection to %s:%u#### (sd=%d)\n",
            inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), sd);
    fflush(stderr);
#endif  
    ctx->network_state.peer_addr       = *name;
    ctx->network_state.peer_addr_len   = namelen;
    ctx->network_state.peer_addr_valid = TRUE;
    if (!ctx->bound)
    {
        int rc;
        if ((rc = _mysock_bind_ephemeral(ctx)) < 0)
            return rc;
    }
    _mysock_transport_init(sd, TRUE);
    return _mysock_wait_for_connection(ctx);
}
int myconnect ( mysocket_t sd , struct sockaddr * name , int namelen ) { mysock_context_t * ctx = _mysock_get_context ( sd ) ; MYSOCK_CHECK ( ctx != NULL , EINVAL ) ; MYSOCK_CHECK ( ( ctx -> network_state . peer_addr_len == 0 ) , EISCONN ) ; #ifdef DEBUG struct sockaddr_in * sin = ( struct sockaddr_in * ) name ; fprintf ( stderr , " \n \n " , inet_ntoa ( sin -> sin_addr ) , ntohs ( sin -> sin_port ) , sd ) ; fflush ( stderr ) ; #endif ctx -> network_state . peer_addr = * name ; ctx -> network_state . peer_addr_len = namelen ; ctx -> network_state . peer_addr_valid = TRUE ; if ( ! ctx -> bound ) { int rc ; if ( ( rc = _mysock_bind_ephemeral ( ctx ) ) < 0 ) return rc ; } _mysock_transport_init ( sd , TRUE ) ; return _mysock_wait_for_connection ( ctx ) ; }
connect to the address specified in name on the mysocket sd
connect to the address specified in name on the mysocket sd
/*DEBUG*/ /* record connection setup for demultiplexing */ /* we need to find the local port number to set up demultiplexing
         * before we send the SYN.  (this is really only required in the VNS
         * case--we have to demultiplex only on listening sockets for the
         * UDP/TCP network layer--but it doesn't do any harm here in
         * general).
         */ /* time for kick off */ /* block until connection is established, or we hit an error */