Print connecting peer's address

This commit is contained in:
Stephen Seo 2024-08-29 16:45:28 +09:00
parent b48f1890bf
commit d46f617b4a

View file

@ -72,6 +72,14 @@ int main(int argc, char **argv) {
printf("WARNING: accept: errno %d\n", errno);
} else if (ret >= 0) {
// Received connection, handle it.
printf("Peer connected: addr is ");
for (unsigned int idx = 0; idx < 16; ++idx) {
if (idx % 2 == 0 && idx > 0) {
printf(":");
}
printf("%02x", peer_info.sin6_addr.s6_addr[idx]);
}
puts("");
int connection_fd = ret;
read_ret = read(connection_fd, recv_buf, C_SIMPLE_HTTP_RECV_BUF_SIZE);
// DEBUG print received buf.