mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-23 01:24:02 +02:00
atrf-proxy.c (loop): use SO_REUSEADDR to avoid "address already in use"
This commit is contained in:
parent
8c5d21b0d7
commit
02b80879bf
@ -239,6 +239,7 @@ static void loop(const char *driver, int port)
|
|||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
int s;
|
int s;
|
||||||
|
int one = 1;
|
||||||
|
|
||||||
s = socket(PF_INET, SOCK_STREAM, 0);
|
s = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
@ -246,6 +247,11 @@ static void loop(const char *driver, int port)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0) {
|
||||||
|
perror("setsockopt");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_port = htons(port);
|
addr.sin_port = htons(port);
|
||||||
|
Loading…
Reference in New Issue
Block a user