[Mplayer-cvslog] CVS: main network.h,NONE,1.1 network.c,1.1,1.2

Bertrand Baudet bertrand at users.sourceforge.net
Sun May 20 14:58:43 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv29445

Modified Files:
	network.c 
Added Files:
	network.h 
Log Message:
Included "netdb.h" file needed.
Changed exit to return -1.


--- NEW FILE ---
#ifndef NETWORK_H
#define NETWORK_H


int connect2Server(char *host, int port);

#endif

Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/network.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** network.c	2001/05/18 16:14:06	1.1
--- network.c	2001/05/20 12:58:41	1.2
***************
*** 1,3 ****
--- 1,5 ----
  #include <unistd.h>
+ #include <netinet/in.h>
+ #include <netdb.h>
  #include <sys/types.h>
  #include <sys/socket.h>
***************
*** 5,26 ****
  #include <stdio.h>
  
  int
  connect2Server(char *host, int port) {
  	int socket_server_fd;
  	struct sockaddr_in server_address;
! 	printf(">>>> connect2Server [%s@%d]\n", host, port );
  	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
  	if( socket_server_fd==-1 ) {
  		perror("Failed to create socket");
! 		exit(1);
  	}
  
  	if( isalpha(host[0]) ) {
! 		struct hostent *hp;
! 		if( (hp=gethostbyname( host ))==NULL ) {
  			printf("Unknown host: %s\n", host);
! 			exit(1);
  		}
! 		memcpy( &server_address.sin_addr.s_addr, hp->h_addr, hp->h_length );
  	} else {
  		inet_pton(AF_INET, host, &server_address.sin_addr);
--- 7,30 ----
  #include <stdio.h>
  
+ #include "network.h"
+ 
  int
  connect2Server(char *host, int port) {
  	int socket_server_fd;
  	struct sockaddr_in server_address;
! 	printf(">>>> connect2Server [%s:%d]\n", host, port );
  	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
  	if( socket_server_fd==-1 ) {
  		perror("Failed to create socket");
! 		return -1;
  	}
  
  	if( isalpha(host[0]) ) {
! 		struct hostent *hp =(struct hostent*)gethostbyname( host );
! 		if( hp==NULL ) {
  			printf("Unknown host: %s\n", host);
! 			return -1;
  		}
! 		memcpy( (void*)&server_address.sin_addr.s_addr, (void*)hp->h_addr, hp->h_length );
  	} else {
  		inet_pton(AF_INET, host, &server_address.sin_addr);
***************
*** 31,36 ****
  	if( connect( socket_server_fd, (struct sockaddr*)&server_address, sizeof(server_address) )==-1 ) {
  		perror("Failed to connect to server");
! 		close(socket_Stream_fd);
! 		exit(1);
  	}
  	return socket_server_fd;
--- 35,40 ----
  	if( connect( socket_server_fd, (struct sockaddr*)&server_address, sizeof(server_address) )==-1 ) {
  		perror("Failed to connect to server");
! 		close(socket_server_fd);
! 		return -1;
  	}
  	return socket_server_fd;


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list