[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_SockAsyncConnect

Overview

Create a remote socket and return immediately

Syntax

    SOCKET Ns_SockAsyncConnect (
    	char		*host,
    	int		port
    );

Description

Ns_SockAsyncConnect creates a socket connected to a remote host and port, returning immediately with the connection in progress. A select call can later be used to determine when the connection has been established.

Example

    SOCKET sock;
    fd_set set;
    struct timeval tv;
    sock = Ns_SockAsyncConnect("mailhost", 25);
    ... perform some other work while connection is in progress...
    
    ... check for connection ...
    tv.tv_sec = 2; /* allow 2 more seconds */
    tv.tv_usec = 0;
    FD_ZERO(&set);
    FD_SET(sock, &set);
    if (select(sock+1, NULL, &set, NULL, &tv) != 1) {
       ... timeout - close socket and return error...
       Ns_CloseLater(sock); 
    } else {
       ... use socket ...
    }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.