From c2b029553bf0cc7f55118460341e1206fe21c4b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 19 Sep 2007 15:31:22 +0000 Subject: [PATCH] Simplify net_Listen (no real use for family and type parameters) --- include/vlc_network.h | 9 ++------- src/network/io.c | 9 +++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/vlc_network.h b/include/vlc_network.h index 68f1696668..bf7c67e6fe 100644 --- a/include/vlc_network.h +++ b/include/vlc_network.h @@ -76,16 +76,11 @@ int net_SetupSocket (int fd); #define net_Connect(a, b, c, d, e) __net_Connect(VLC_OBJECT(a), b, c, d, e) VLC_EXPORT( int, __net_Connect, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) ); -VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int family, int socktype, int protocol) ); +VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int protocol) ); -#define net_ListenTCP(a, b, c) __net_ListenTCP(VLC_OBJECT(a), b, c) +#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, IPPROTO_TCP) #define net_ConnectTCP(a, b, c) __net_ConnectTCP(VLC_OBJECT(a), b, c) -static inline int *__net_ListenTCP (vlc_object_t *obj, const char *host, int port) -{ - return net_Listen (obj, host, port, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); -} - static inline int __net_ConnectTCP (vlc_object_t *obj, const char *host, int port) { return __net_Connect (obj, host, port, SOCK_STREAM, IPPROTO_TCP); diff --git a/src/network/io.c b/src/network/io.c index b28233590e..199a52d820 100644 --- a/src/network/io.c +++ b/src/network/io.c @@ -119,13 +119,14 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype, int *net_Listen (vlc_object_t *p_this, const char *psz_host, - int i_port, int family, int socktype, int protocol) + int i_port, int protocol) { struct addrinfo hints, *res; memset (&hints, 0, sizeof( hints )); - hints.ai_family = family; - hints.ai_socktype = socktype; + /* Since we use port numbers rather than service names, the socket type + * does not really matter. */ + hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; msg_Dbg (p_this, "net: listening to %s port %d", psz_host, i_port); @@ -144,7 +145,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, for (struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next) { int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype, - protocol ?: ptr->ai_protocol); + protocol); if (fd == -1) { msg_Dbg (p_this, "socket error: %m"); -- 2.39.5