Implement what has been documented for a long time: make -debug switch
on socket debugging. Okay'ed by: markm
This commit is contained in:
parent
a9ca5bdbd0
commit
c7d4f4371f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118865
@ -348,6 +348,9 @@ main(int argc, char *argv[])
|
|||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
(void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
(void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(char *)&on, sizeof(on));
|
(char *)&on, sizeof(on));
|
||||||
|
if (debug > 1)
|
||||||
|
(void) setsockopt(s, SOL_SOCKET, SO_DEBUG,
|
||||||
|
(char *)&on, sizeof(on));
|
||||||
if (bind(s, res->ai_addr, res->ai_addrlen) < 0)
|
if (bind(s, res->ai_addr, res->ai_addrlen) < 0)
|
||||||
err(1, "bind");
|
err(1, "bind");
|
||||||
if (listen(s, 1) < 0)
|
if (listen(s, 1) < 0)
|
||||||
@ -356,6 +359,8 @@ main(int argc, char *argv[])
|
|||||||
ns = accept(s, res->ai_addr, &foo);
|
ns = accept(s, res->ai_addr, &foo);
|
||||||
if (ns < 0)
|
if (ns < 0)
|
||||||
err(1, "accept");
|
err(1, "accept");
|
||||||
|
(void) setsockopt(ns, SOL_SOCKET, SO_DEBUG,
|
||||||
|
(char *)&on, sizeof(on));
|
||||||
(void) dup2(ns, 0);
|
(void) dup2(ns, 0);
|
||||||
(void) close(ns);
|
(void) close(ns);
|
||||||
(void) close(s);
|
(void) close(s);
|
||||||
|
Loading…
Reference in New Issue
Block a user