Print connecting peer's address
This commit is contained in:
parent
b48f1890bf
commit
d46f617b4a
1 changed files with 8 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue