#include <errno.h>
#include <assert.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
#ifdef HAVE_POLL
# include <poll.h>
#endif
#include <vlc_network.h>
-#if defined (WIN32) || defined (UNDER_CE)
+#if defined (_WIN32)
# undef EINPROGRESS
# define EINPROGRESS WSAEWOULDBLOCK
# undef EWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK
+# undef EAGAIN
+# define EAGAIN WSAEWOULDBLOCK
# undef EINTR
# define EINTR WSAEINTR
-# undef ETIMEDOUT
-# define ETIMEDOUT WSAETIMEDOUT
#endif
#include "libvlc.h" /* vlc_object_waitpipe */
struct addrinfo hints = {
.ai_socktype = type,
.ai_protocol = proto,
- .ai_flags = AI_NUMERICSERV,
+ .ai_flags = AI_NUMERICSERV | AI_IDN,
}, *res;
int val = vlc_getaddrinfo (psz_realhost, i_realport, &hints, &res);
- free( psz_socks );
if (val)
{
msg_Err (p_this, "cannot resolve %s port %d : %s", psz_realhost,
i_realport, gai_strerror (val));
+ free( psz_socks );
return -1;
}
+ free( psz_socks );
int timeout = var_InheritInteger (p_this, "ipv4-timeout");
if (timeout < 0)
ptr->ai_socktype, ptr->ai_protocol );
if( fd == -1 )
{
- msg_Dbg( p_this, "socket error: %m" );
+ msg_Dbg( p_this, "socket error: %s", vlc_strerror_c(net_errno) );
continue;
}
if( net_errno != EINPROGRESS && net_errno != EINTR )
{
- msg_Err( p_this, "connection failed: %m" );
+ msg_Err( p_this, "connection failed: %s",
+ vlc_strerror_c(net_errno) );
goto next_ai;
}
switch (val)
{
case -1: /* error */
- msg_Err (p_this, "connection polling error: %m");
+ msg_Err (p_this, "polling error: %s",
+ vlc_strerror_c(net_errno));
goto next_ai;
case 0: /* timeout */
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &val,
&(socklen_t){ sizeof (val) }) || val)
{
- errno = val;
- msg_Err (p_this, "connection failed: %m");
+ msg_Err (p_this, "connection failed: %s",
+ vlc_strerror_c(val));
goto next_ai;
}
}
if (fd == -1)
{
if (net_errno != EAGAIN && net_errno != EWOULDBLOCK)
- msg_Err (obj, "accept failed (from socket %d): %m", lfd);
+ msg_Err (obj, "accept failed (from socket %d): %s", lfd,
+ vlc_strerror_c(net_errno));
return -1;
}
{
if (net_errno != EINTR)
{
- msg_Err (p_this, "poll error: %m");
+ msg_Err (p_this, "poll error: %s", vlc_strerror_c(net_errno));
return -1;
}
}
return VLC_SUCCESS;
/* We negotiate authentication */
-
- if( ( psz_socks_user == NULL ) && ( psz_socks_passwd == NULL ) )
- b_auth = true;
-
buffer[0] = i_socks_version; /* SOCKS version */
- if( b_auth )
+ if( psz_socks_user != NULL && psz_socks_passwd != NULL )
{
buffer[1] = 2; /* Number of methods */
buffer[2] = 0x00; /* - No auth required */
buffer[3] = 0x02; /* - USer/Password */
i_len = 4;
+ b_auth = true;
}
else
{
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
.ai_protocol = IPPROTO_TCP,
- .ai_flags = 0,
+ .ai_flags = AI_IDN,
};
struct addrinfo *res;