Implement what has been documented for a long time: make -debug switch

on socket debugging.

Okay'ed by: markm


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@118865 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
harti 2003-08-13 10:56:40 +00:00
parent 4369ac2a7f
commit 6a39aef766
1 changed files with 5 additions and 0 deletions

View File

@ -348,6 +348,9 @@ main(int argc, char *argv[])
err(1, "socket");
(void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
(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)
err(1, "bind");
if (listen(s, 1) < 0)
@ -356,6 +359,8 @@ main(int argc, char *argv[])
ns = accept(s, res->ai_addr, &foo);
if (ns < 0)
err(1, "accept");
(void) setsockopt(ns, SOL_SOCKET, SO_DEBUG,
(char *)&on, sizeof(on));
(void) dup2(ns, 0);
(void) close(ns);
(void) close(s);