Back to index

avfs  1.0.1
Functions
socket.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int av_sock_connect (const char *name, int defaultport)

Function Documentation

int av_sock_connect ( const char *  name,
int  defaultport 
)

Definition at line 57 of file socket.c.

{
    char *hostname;
    char *s;
    int port = defaultport;
    int sock;

    hostname = av_strdup(name);
    s = strrchr(hostname, ':');
    if(s != NULL) {
        char *end;

        *s = '\0';
        s++;
        port = strtol(s, &end, 10);
        if(end == s || *end != '\0') {
            av_free(hostname);
            av_log(AVLOG_ERROR, "Bad port: %s", name);
            return -ENOENT;
        }
    }
    else if(defaultport == -1) {
        av_free(hostname);
        av_log(AVLOG_ERROR, "Missing port: %s", name);
        return -ENOENT;
    }
    
    sock = sock_connect_host(hostname, port);
    av_free(hostname);
    
    return sock;
}

Here is the call graph for this function:

Here is the caller graph for this function: