| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 1.91

 

connect_TCP

#include "sflsock.h"
sock_t
connect_TCP (
    const char *host,                   /*  Host name                        */
    const char *service                 /*  Service name                     */
)

Synopsis

Creates a TCP socket and connects it to a specified host and service. Returns a socket number or INVALID_SOCKET. In that case you can get the reason for the error by calling connect error (). This may be:
IP NOSOCKETS Sockets not supported on this system
IP BADHOST Host is not known
IP BADPROTOCOL Cannot understand protocol name
IP SOCKETERROR Cannot open a socket
IP CONNECTERROR Cannot connect socket
The host name may be a full name, NULL or "" meaning the current host, or a dotted-decimal number. The service may be a defined service, e.g. "echo", or a port number, specified as an ASCII string. See connect socket() for details. Adds the current value ip_portbase to the port number.

Examples

    sock_t handle;
    handle = connect_TCP ("", "8080");
    handle = connect_TCP (NULL, "echo");
    handle = connect_TCP ("www.imatix.com", "http");

Source Code - (sflsock.c)

{
    ASSERT (service && *service);
    return (connect socket (host,       /*  We have a host name              */
                            service,    /*  We have a service name           */
                            "tcp",      /*  Protocol is TCP                  */
                            NULL,       /*  No prepared address              */
                            3, 0));     /*  3 retries, no waiting            */
}

| << | < | > | >> iMatix Copyright © 1996-98 iMatix