8000 Print client IP address when a new chat starts · vpodaruev/programming-with-cpp@b2dd98f · GitHub
[go: up one dir, main page]

Skip to content

Commit b2dd98f

Browse files
committed
Print client IP address when a new chat starts
1 parent 9d84661 commit b2dd98f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

projects/messenger/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ void run_as_server (unsigned port)
3232
std::this_thread::sleep_for(500ms);
3333
continue;
3434
}
35-
std::cout << "*** Has connection. Chat starts ***" << std::endl;
35+
auto ip = stream.rdbuf()->remote_endpoint().address().to_string();
36+
std::cout << "Has connection from " << ip << "\n"
37+
<< "*** Chat starts ***" << std::endl;
3638

3739
while (stream && std::cin)
3840
{

0 commit comments

Comments
 (0)
0