fixed missing SO_REUSE* in old kernels

master
Ismael Gomez 8 years ago
parent d970aecd6c
commit f3b87ca955

@ -48,10 +48,14 @@ int srslte_netsink_init(srslte_netsink_t *q, char *address, int port, srslte_net
} }
int enable = 1; int enable = 1;
#if defined (SO_REUSEADDR)
if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0)
perror("setsockopt(SO_REUSEADDR) failed"); perror("setsockopt(SO_REUSEADDR) failed");
#endif
#if defined (SO_REUSEPORT)
if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int)) < 0) if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int)) < 0)
perror("setsockopt(SO_REUSEPORT) failed"); perror("setsockopt(SO_REUSEPORT) failed");
#endif
q->servaddr.sin_family = AF_INET; q->servaddr.sin_family = AF_INET;
q->servaddr.sin_addr.s_addr=inet_addr(address); q->servaddr.sin_addr.s_addr=inet_addr(address);

@ -48,11 +48,14 @@ int srslte_netsource_init(srslte_netsource_t *q, char *address, int port, srslte
// Make sockets reusable // Make sockets reusable
int enable = 1; int enable = 1;
#if defined (SO_REUSEADDR)
if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0)
perror("setsockopt(SO_REUSEADDR) failed"); perror("setsockopt(SO_REUSEADDR) failed");
#endif
#if defined (SO_REUSEPORT)
if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int)) < 0) if (setsockopt(q->sockfd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int)) < 0)
perror("setsockopt(SO_REUSEPORT) failed"); perror("setsockopt(SO_REUSEPORT) failed");
#endif
q->type = type; q->type = type;
q->servaddr.sin_family = AF_INET; q->servaddr.sin_family = AF_INET;

Loading…
Cancel
Save