- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(port);
- serv_addr.sin_addr = *((struct in_addr *) hostinfo->h_addr );
- memset( &( serv_addr.sin_zero ), '\0', 8 ); /* Clear the rest of the structure. */
-
- if( wmnotify_infos.debug ) {
- printf( " Server IP = %s\n", inet_ntoa( serv_addr.sin_addr ) );
- printf( " Server port = %d\n", ntohs(serv_addr.sin_port) );
- }
-
- /* Establishing connection. */
- status = connect( sock_fd, (struct sockaddr *) &(serv_addr), sizeof(serv_addr) );
- if( status < 0 ) {
- perror( PACKAGE );
- ErrorLocation( __FILE__, __LINE__ );
- goto error;
- }
-
- end:
- return sock_fd;
-
- error:
- if( sock_fd >= 0 ) {
- status = close( sock_fd );
- if( status < 0 ) {
- perror( PACKAGE );
- ErrorLocation( __FILE__, __LINE__ );
- }
- }
-
- sock_fd = -1;
- goto end;
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_port = htons(port);
+ serv_addr.sin_addr = *((struct in_addr *)hostinfo->h_addr);
+ memset(&(serv_addr.sin_zero), '\0', 8); /* Clear rest of structure. */
+
+ if (wmnotify_infos.debug) {
+ printf(" Server IP = %s\n",
+ inet_ntoa(serv_addr.sin_addr));
+ printf(" Server port = %d\n", ntohs(serv_addr.sin_port));
+ }
+
+ /* Establishing connection. */
+ status = connect(sock_fd, (struct sockaddr *)&(serv_addr),
+ sizeof(serv_addr));
+ if (status < 0) {
+ perror(PACKAGE);
+ ErrorLocation(__FILE__, __LINE__);
+ goto error;
+ }
+
+end:
+ return sock_fd;
+
+error:
+ if (sock_fd >= 0) {
+ status = close(sock_fd);
+ if (status < 0) {
+ perror(PACKAGE);
+ ErrorLocation(__FILE__, __LINE__);
+ }
+ }
+
+ sock_fd = -1;
+ goto end;