Skip to content

Commit

Permalink
Make servers more verbose about connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Jan 31, 2025
1 parent 153a3e5 commit 9822f8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ static void tcp_to_ncp (const char *port, const char *host, const char *sock)
int connection, foreign_port;
int fd, s, size;

fprintf (stderr, "Listening to port %s.\n", port);

s = inet_server (port);
fd = inet_accept (s, &foreign_host, &foreign_port);
fprintf (stderr, "Connection from host %s on port %d.\n",
Expand All @@ -161,6 +163,7 @@ static void tcp_to_ncp (const char *port, const char *host, const char *sock)
exit (1);
}

fprintf (stderr, "Forwarding to host %d socket %d.\n", ncp_host, ncp_sock);
transport (fd, connection);

if (ncp_close (connection) == -1) {
Expand All @@ -173,6 +176,8 @@ static void ncp_to_tcp (int sock, const char *host, const char *port)
{
int fd, ncp_host, connection, size;

fprintf (stderr, "Listening to socket %d.\n", sock);

size = 8;
if (ncp_listen (sock, &size, &ncp_host, &connection) == -1) {
fprintf (stderr, "NCP listen error.\n");
Expand All @@ -181,6 +186,7 @@ static void ncp_to_tcp (int sock, const char *host, const char *port)
fprintf (stderr, "Connection from host %03o on socket %d.\n", ncp_host, sock);

fd = inet_connect (host, port);
fprintf (stderr, "Forwarding to host %s port %s.\n", host, port);
transport (fd, connection);

if (ncp_close (connection) == -1)
Expand Down
1 change: 1 addition & 0 deletions apps/telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ static void telnet_server (int host, int sock,
fprintf (stderr, "NCP listen error.\n");
exit (1);
}
fprintf (stderr, "Connection from host %03o.\n", host);

reader_fd = reader (connection);
writer_fd = writer (connection);
Expand Down

0 comments on commit 9822f8a

Please sign in to comment.