server 0.0.1
basicserverinfrastructure

src/socket/connect.c

Go to the documentation of this file.
00001 #include <stdlib.h>     /* for atoi() and exit() */
00002 #include <errno.h>      /* for errno */
00003 
00004 #include "socket.h"
00005 #include "interface/class.h"
00006 #include "interface/logger.h"
00007 
00008 
00009 void
00010 socketConnect(Sock this, const char * addr)
00011 {
00012         inet_pton(AF_INET, addr, &((this->addr).sin_addr));
00013     (this->addr).sin_family = AF_INET;           /* Internet address family */
00014     (this->addr).sin_port   = htons(this->port); /* Local port */
00015 
00016         if (-1 == connect(this->handle, (struct sockaddr*) &(this->addr), sizeof(this->addr))) {
00017         loggerLog(this->log, LOGGER_CRIT,
00018                 "error connection socket: %s - service terminated",
00019                 strerror(errno));
00020         exit(EXIT_FAILURE);
00021     }
00022 }
00023 
00024 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines