diff libmpdemux/network.c @ 3494:fb9de639ed30

Applied the patch from Alban Bedel <albeu@free.fr>. He added some errors checking on network code. Added a check on the port number parsing in the url.
author bertrand
date Fri, 14 Dec 2001 20:45:30 +0000
parents 10577da4a7b1
children cb985ea11ed5
line wrap: on
line diff
--- a/libmpdemux/network.c	Fri Dec 14 20:14:59 2001 +0000
+++ b/libmpdemux/network.c	Fri Dec 14 20:45:30 2001 +0000
@@ -137,6 +137,17 @@
 
 	// Turn back the socket as blocking
 	fcntl( socket_server_fd, F_SETFL, fcntl(socket_server_fd, F_GETFL) & ~O_NONBLOCK );
+	// Check if there were any error
+	err_len = sizeof(int);
+	ret =  getsockopt(socket_server_fd,SOL_SOCKET,SO_ERROR,&err,&err_len);
+	if(ret < 0) {
+		printf("getsockopt failed : %s\n",strerror(errno));
+		return -1;
+	}
+	if(err > 0) {
+		printf("Connect error : %s\n",strerror(err));
+		return -1;
+	}
 	return socket_server_fd;
 }
 
@@ -356,8 +367,8 @@
 	if( len<size ) {
 		int ret;
 		ret = read( fd, buffer+len, size-len );
-		if( ret==0 ) {
-			printf("nop_streaming_read read 0 -ie- EOF\n");
+		if( ret<0 ) {
+			printf("nop_streaming_read error : %s\n",strerror(errno));
 		}
 		len += ret;
 //printf("read %d bytes from network\n", len );