File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,9 @@ namespace simpleApp
4141
4242 std::string addressToString (sockaddr_in& address)
4343 {
44- uint32_t addressConverted = ntohl (address.sin_addr .s_addr );
4544 auto portConverted = ntohs (address.sin_port );
4645
47- uint8_t * addressByBytes = reinterpret_cast <uint8_t *>(&addressConverted );
46+ uint8_t * addressByBytes = reinterpret_cast <uint8_t *>(&address. sin_addr . s_addr );
4847
4948 return std::to_string (static_cast <int >(addressByBytes[0 ])) + std::string (" ." ) +
5049 std::to_string (static_cast <int >(addressByBytes[1 ])) + std::string (" ." ) +
Original file line number Diff line number Diff line change 33#include < stdlib.h>
44#include < unistd.h>
55
6+ #include < stdio.h>
7+ #include < termios.h>
8+ #include < time.h>
9+ #include < sys/ioctl.h>
10+
11+ #include < cstring>
12+
613#include " Server.hpp"
714
815simpleApp::Server server = simpleApp::Server();
@@ -17,6 +24,16 @@ void onExit(int s)
1724
1825int main (int argc, char ** argv)
1926{
27+ // Hide console input
28+ termios orig_term_attr;
29+ termios new_term_attr;
30+ tcgetattr (fileno (stdin), &orig_term_attr);
31+ memcpy (&new_term_attr, &orig_term_attr, sizeof (termios));
32+ new_term_attr.c_lflag &= ~(ECHO | ICANON);
33+ new_term_attr.c_cc [VTIME] = 0 ;
34+ new_term_attr.c_cc [VMIN] = 0 ;
35+ tcsetattr (fileno (stdin), TCSANOW, &new_term_attr);
36+
2037 std::cout << " Welcome to the SimpleServer!" << std::endl <<
2138 " For exit press Ctrl+C" << std::endl;
2239
@@ -39,5 +56,5 @@ int main(int argc, char** argv)
3956 return -1 ;
4057 }
4158
42- return server.serverLoop (static_cast <uint16_t >(35831 ));
59+ return server.serverLoop (static_cast <uint16_t >(35830 ));
4360}
You can’t perform that action at this time.
0 commit comments