# HG changeset patch # User bertrand # Date 1031016584 0 # Node ID cc83ad6af5134e4d05821ec6cc014297bcc0045a # Parent 27a1315d6af431b96801a5d333130b1524335023 Return -2 for fatal error while connecting to a server. Fatal are unable to resolve name, connection timeout... diff -r 27a1315d6af4 -r cc83ad6af513 libmpdemux/network.c --- 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));