File tree Expand file tree Collapse file tree
include/simple_socket/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ #ifndef SIMPLE_SOCKET_NET_BYTE_ORDER_HPP
3+ #define SIMPLE_SOCKET_NET_BYTE_ORDER_HPP
4+
5+ #include < cstdint>
6+
7+ namespace simple_socket {
8+
9+ uint32_t ss_htons (uint16_t hostshort);
10+ uint16_t ss_ntohs (uint32_t netshort);
11+
12+ }// namespace simple_socket
13+
14+ #endif // SIMPLE_SOCKET_NET_BYTE_ORDER_HPP
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ set(sources
3232
3333 "simple_socket/http/SimpleHttpFetcher.cpp"
3434
35+ "simple_socket/util/net_byteorder.cpp"
3536 "simple_socket/util/port_query.cpp"
3637)
3738
Original file line number Diff line number Diff line change 1+
2+ #ifdef _WIN32
3+ #include < WinSock2.h>
4+ #else
5+ #include < arpa/inet.h>
6+ #endif
7+
8+ #include " simple_socket/util/net_byteorder.hpp"
9+
10+ using namespace simple_socket ;
11+
12+ uint32_t ss_htons (uint16_t hostshort) {
13+ return ::htons (hostshort);
14+ }
15+
16+ uint16_t ss_ntohs (uint32_t netshort) {
17+ return ::ntohs (static_cast <uint16_t >(netshort));
18+ }
You can’t perform that action at this time.
0 commit comments