| iMatix home page
| << | < | > | >>
Version 2.11



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


Creates a UDP 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. Single-threaded clients may set ip_nonblock to FALSE and block on all read and write operations. They may use select() if they need to be able to time-out during reading/writing. Multi-threaded servers should set ip_nonblock to TRUE, and use select() to multiplex socket access. When ip_nonblock is TRUE, connect calls will return immediately, and the server should use select() to wait until the socket is ready for writing. On some systems (early Linux?), the select() call will fail in this situation. If you compile with -DBLOCKING_CONNECT, connects are done synchronously in all cases.


    sock_t handle;
    handle = connect_UDP ("", "7");
    handle = connect_UDP (NULL, "echo");
    handle = connect_UDP ("imatix.com", "echo");

Source Code - (sflsock.c)

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

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation