summaryrefslogtreecommitdiffstats
path: root/stream/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'stream/tcp.c')
-rw-r--r--stream/tcp.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/stream/tcp.c b/stream/tcp.c
index ac3165b1a7..b299e9d66f 100644
--- a/stream/tcp.c
+++ b/stream/tcp.c
@@ -42,7 +42,7 @@ int network_prefer_ipv4 = 0;
static const char *af2String(int af) {
switch (af) {
case AF_INET: return "AF_INET";
-
+
#ifdef HAVE_AF_INET6
case AF_INET6: return "AF_INET6";
#endif
@@ -74,17 +74,17 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
void *our_s_addr; // Pointer to sin_addr or sin6_addr
struct hostent *hp=NULL;
char buf[255];
-
+
#if HAVE_WINSOCK2_H
unsigned long val;
int to;
#else
struct timeval to;
#endif
-
+
socket_server_fd = socket(af, SOCK_STREAM, 0);
-
-
+
+
if( socket_server_fd==-1 ) {
// mp_msg(MSGT_NETWORK,MSGL_ERR,"Failed to create %s socket:\n", af2String(af));
return TCP_ERROR_FATAL;
@@ -111,10 +111,10 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
mp_msg(MSGT_NETWORK,MSGL_ERR, MSGTR_MPDEMUX_NW_UnknownAF, af);
return TCP_ERROR_FATAL;
}
-
-
+
+
memset(&server_address, 0, sizeof(server_address));
-
+
#if HAVE_INET_PTON
if (inet_pton(af, host, our_s_addr)!=1)
#elif HAVE_INET_ATON
@@ -124,7 +124,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
#endif
{
if(verb) mp_msg(MSGT_NETWORK,MSGL_STATUS,MSGTR_MPDEMUX_NW_ResolvingHostForAF, host, af2String(af));
-
+
#ifdef HAVE_GETHOSTBYNAME2
hp=(struct hostent*)gethostbyname2( host, af );
#else
@@ -134,7 +134,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
if(verb) mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_CantResolv, af2String(af), host);
return TCP_ERROR_FATAL;
}
-
+
memcpy( our_s_addr, (void*)hp->h_addr_list[0], hp->h_length );
}
#if HAVE_WINSOCK2_H
@@ -143,14 +143,14 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
memcpy( our_s_addr, (void*)&addr, sizeof(addr) );
}
#endif
-
+
switch (af) {
case AF_INET:
server_address.four.sin_family=af;
- server_address.four.sin_port=htons(port);
+ server_address.four.sin_port=htons(port);
server_address_size = sizeof(server_address.four);
break;
-#ifdef HAVE_AF_INET6
+#ifdef HAVE_AF_INET6
case AF_INET6:
server_address.six.sin6_family=af;
server_address.six.sin6_port=htons(port);
@@ -226,7 +226,7 @@ connect2Server_with_af(char *host, int port, int af,int verb) {
mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ConnectError,strerror(err));
return TCP_ERROR_PORT;
}
-
+
return socket_server_fd;
}
@@ -241,15 +241,15 @@ connect2Server(char *host, int port, int verb) {
int r;
int s = TCP_ERROR_FATAL;
- r = connect2Server_with_af(host, port, network_prefer_ipv4 ? AF_INET:AF_INET6,verb);
+ r = connect2Server_with_af(host, port, network_prefer_ipv4 ? AF_INET:AF_INET6,verb);
if (r >= 0) return r;
s = connect2Server_with_af(host, port, network_prefer_ipv4 ? AF_INET6:AF_INET,verb);
if (s == TCP_ERROR_FATAL) return r;
return s;
-#else
+#else
return connect2Server_with_af(host, port, AF_INET,verb);
#endif
-
+
}