diff options
author | bertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-09-03 01:29:44 +0000 |
---|---|---|
committer | bertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-09-03 01:29:44 +0000 |
commit | 89250197603f2293bc642fef0cfaeacf9bf05849 (patch) | |
tree | 98981c1ab2797ebd37eb372fd329b83dd3ed32d1 /libmpdemux | |
parent | c5cc04f2c85aacb57aca118fdc2e1092ee7207e2 (diff) |
Return -2 for fatal error while connecting to a server.
Fatal are unable to resolve name, connection timeout...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7252 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/network.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libmpdemux/network.c b/libmpdemux/network.c index 9ab2e5a21d..252f26b843 100644 --- a/libmpdemux/network.c +++ b/libmpdemux/network.c @@ -138,6 +138,8 @@ read_rtp_from_server(int fd, char *buffer, int length) { #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 @@ connect2Server(char *host, int port) { 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 @@ connect2Server(char *host, int port) { 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 @@ connect2Server(char *host, int port) { 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 @@ connect2Server(char *host, int port) { 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)); |