changeset 7251:cc83ad6af513

Return -2 for fatal error while connecting to a server. Fatal are unable to resolve name, connection timeout...
author bertrand
date Tue, 03 Sep 2002 01:29:44 +0000
parents 27a1315d6af4
children 0a0527c82560
files libmpdemux/network.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/network.c	Tue Sep 03 01:25:31 2002 +0000
+++ b/libmpdemux/network.c	Tue Sep 03 01:29:44 2002 +0000
@@ -138,6 +138,8 @@
 #endif
 
 // Connect to a server using a TCP connection
+// return -2 for fatal error, like unable to resolve name, connection timeout...
+// return -1 is unable to connect to a particular port
 int
 connect2Server(char *host, int port) {
 	int socket_server_fd;
@@ -152,7 +154,7 @@
 	socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
 	if( socket_server_fd==-1 ) {
 		mp_msg(MSGT_NETWORK,MSGL_ERR,"Failed to create socket\n");
-		return -1;
+		return -2;
 	}
 
 	if( isalpha(host[0]) ) {
@@ -160,7 +162,7 @@
 		hp=(struct hostent*)gethostbyname( host );
 		if( hp==NULL ) {
 			mp_msg(MSGT_NETWORK,MSGL_ERR,"Counldn't resolve name: %s\n", host);
-			return -1;
+			return -2;
 		}
 		memcpy( (void*)&server_address.sin_addr.s_addr, (void*)hp->h_addr, hp->h_length );
 	} else {
@@ -191,7 +193,7 @@
 		  mp_msg(MSGT_NETWORK,MSGL_ERR,"Connection timeout\n");
 		else
 		  mp_msg(MSGT_NETWORK,MSGL_V,"Connection interuppted by user\n");
-		return -1;
+		return -2;
 	      }
 	      count++;
 	      FD_ZERO( &set );
@@ -207,7 +209,7 @@
 	ret =  getsockopt(socket_server_fd,SOL_SOCKET,SO_ERROR,&err,&err_len);
 	if(ret < 0) {
 		mp_msg(MSGT_NETWORK,MSGL_ERR,"getsockopt failed : %s\n",strerror(errno));
-		return -1;
+		return -2;
 	}
 	if(err > 0) {
 		mp_msg(MSGT_NETWORK,MSGL_ERR,"Connect error : %s\n",strerror(err));