File tree Expand file tree Collapse file tree 9 files changed +62
-55
lines changed Expand file tree Collapse file tree 9 files changed +62
-55
lines changed Original file line number Diff line number Diff line change 8
8
#endif
9
9
10
10
namespace asock {
11
- #if defined __APPLE__ || defined __linux__
12
11
class ASockIpcClient : public asock ::ASockBase {
13
12
public :
13
+ #if defined __APPLE__ || defined __linux__
14
14
// - If you know the maximum data size you will be sending and receiving in advance,
15
15
// it is better to allocate a buffer large enough to match that.
16
16
// - If you do not know the size in advance or if it exceeds the buffer,
@@ -36,7 +36,20 @@ public :
36
36
sock_usage_ = SOCK_USAGE_IPC_CLIENT;
37
37
}
38
38
#elif WIN32
39
- // TODO: windows
39
+ // TODO: Not implemented on Windows.
40
+ bool InitIpcClient (const char * sock_path,
41
+ int connect_timeout_secs=10 ,
42
+ size_t max_data_len=asock::DEFAULT_BUFFER_SIZE) {
43
+ err_msg_ = " not implemented" ;
44
+ ELOG (err_msg_);
45
+ return false ;
46
+ }
47
+
48
+ void SetUsage () override {
49
+ err_msg_ = " not implemented" ;
50
+ ELOG (err_msg_);
51
+ sock_usage_ = SOCK_USAGE_UNKNOWN;
52
+ }
40
53
#endif
41
54
};
42
55
} // namespace
Original file line number Diff line number Diff line change 8
8
#endif
9
9
10
10
namespace asock {
11
- #if defined __APPLE__ || defined __linux__
12
11
class ASockIpcServer : public asock ::ASockBase {
13
12
public :
13
+ #if defined __APPLE__ || defined __linux__
14
14
// - If you know the maximum data size you will be sending and receiving in advance,
15
15
// it is better to allocate a buffer large enough to match that.
16
16
// - If you do not know the size in advance or if it exceeds the buffer,
@@ -34,9 +34,22 @@ public :
34
34
void SetUsage () override {
35
35
sock_usage_ = SOCK_USAGE_IPC_SERVER;
36
36
}
37
- };
38
37
#elif WIN32
39
- // TODO: windows
38
+ // TODO: Not implemented on Windows.
39
+ bool RunIpcServer (const char * sock_path,
40
+ size_t max_data_len=asock::DEFAULT_BUFFER_SIZE,
41
+ size_t max_event=asock::DEFAULT_MAX_EVENT){
42
+ err_msg_ = " not implemented" ;
43
+ ELOG (err_msg_);
44
+ return false ;
45
+ }
46
+
47
+ void SetUsage () override {
48
+ err_msg_ = " not implemented" ;
49
+ ELOG (err_msg_);
50
+ sock_usage_ = SOCK_USAGE_UNKNOWN;
51
+ }
40
52
#endif
53
+ };
41
54
} // namespace
42
55
#endif
Original file line number Diff line number Diff line change @@ -27,37 +27,22 @@ elseif(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux")
27
27
add_definitions (-Wall -Werror -Wextra -Wpedantic )
28
28
endif ()
29
29
30
- if (WIN32 )
31
- set (SAMPLE_FILES
32
- client_tcp_comp.cpp
33
- client_tcp_eo.cpp
34
- client_tcp_inh.cpp
35
- client_udp_comp.cpp
36
- client_udp_inh.cpp
37
- server_tcp_comp.cpp
38
- server_tcp_eo.cpp
39
- server_tcp_inh.cpp
40
- server_udp_comp.cpp
41
- server_udp_inh.cpp
42
- )
43
- elseif (APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux" )
44
- set (SAMPLE_FILES
45
- client_tcp_comp.cpp
46
- client_tcp_eo.cpp
47
- client_tcp_inh.cpp
48
- client_udp_comp.cpp
49
- client_udp_inh.cpp
50
- server_tcp_comp.cpp
51
- server_tcp_eo.cpp
52
- server_tcp_inh.cpp
53
- server_udp_comp.cpp
54
- server_udp_inh.cpp
55
- client_ipc_comp.cpp
56
- client_ipc_inh.cpp
57
- server_ipc_comp.cpp
58
- server_ipc_inh.cpp
59
- )
60
- endif ()
30
+ set (SAMPLE_FILES
31
+ client_tcp_comp.cpp
32
+ client_tcp_eo.cpp
33
+ client_tcp_inh.cpp
34
+ client_udp_comp.cpp
35
+ client_udp_inh.cpp
36
+ server_tcp_comp.cpp
37
+ server_tcp_eo.cpp
38
+ server_tcp_inh.cpp
39
+ server_udp_comp.cpp
40
+ server_udp_inh.cpp
41
+ client_ipc_comp.cpp
42
+ client_ipc_inh.cpp
43
+ server_ipc_comp.cpp
44
+ server_ipc_inh.cpp
45
+ )
61
46
62
47
foreach (samplefile ${SAMPLE_FILES} )
63
48
get_filename_component (exename ${samplefile} NAME_WE )
Original file line number Diff line number Diff line change 6
6
#include < csignal>
7
7
#include " asock/asock_ipc_client.hpp"
8
8
9
+ // NOTE: Not implemented on Windows.
9
10
// The buffer must be large enough to hold the entire data.
10
11
#define DEFAULT_PACKET_SIZE 1024
11
12
// /////////////////////////////////////////////////////////////////////////////
@@ -96,7 +97,7 @@ int main(int argc, char* argv[]) {
96
97
while ( client.IsConnected () ) {
97
98
std::cin.clear ();
98
99
getline (std::cin, user_msg);
99
- int msg_len = user_msg.length ();
100
+ int msg_len = ( int ) user_msg.length ();
100
101
if (msg_len>0 ) {
101
102
if (! client.SendToServer (user_msg.c_str (),msg_len) ) {
102
103
std::cerr << client.GetLastErrMsg () <<" \n " ;
Original file line number Diff line number Diff line change 6
6
#include < csignal>
7
7
#include " asock/asock_ipc_client.hpp"
8
8
9
+ // NOTE: Not implemented on Windows.
9
10
// The buffer must be large enough to hold the entire data.
10
11
#define DEFAULT_PACKET_SIZE 1024
11
12
// /////////////////////////////////////////////////////////////////////////////
@@ -70,7 +71,7 @@ int main(int argc, char* argv[]) {
70
71
while ( client.IsConnected () ) {
71
72
std::cin.clear ();
72
73
getline (std::cin, user_msg);
73
- int msg_len = user_msg.length ();
74
+ int msg_len = ( int ) user_msg.length ();
74
75
if (msg_len>0 ) {
75
76
if (! client.SendToServer (user_msg.c_str (),user_msg.length ()) ) {
76
77
std::cerr << client.GetLastErrMsg () <<" \n " ;
Original file line number Diff line number Diff line change 4
4
#include < csignal>
5
5
#include " asock/asock_ipc_server.hpp"
6
6
7
+ // NOTE: Not implemented on Windows.
7
8
// The buffer must be large enough to hold the entire data.
8
9
#define DEFAULT_PACKET_SIZE 1024
9
10
// /////////////////////////////////////////////////////////////////////////////
@@ -100,7 +101,7 @@ int main(int argc, char* argv[]) {
100
101
}
101
102
std::cout << " server started" << " \n " ;
102
103
while ( server.IsServerRunning () ) {
103
- sleep ( 1 );
104
+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ) );
104
105
}
105
106
std::cout << " server exit...\n " ;
106
107
exit (EXIT_SUCCESS);
Original file line number Diff line number Diff line change 4
4
#include < csignal>
5
5
#include " asock/asock_ipc_server.hpp"
6
6
7
+ // NOTE: Not implemented on Windows.
7
8
// The buffer must be large enough to hold the entire data.
8
9
#define DEFAULT_PACKET_SIZE 1024
9
10
// /////////////////////////////////////////////////////////////////////////////
@@ -74,7 +75,7 @@ int main(int argc, char* argv[]) {
74
75
exit (EXIT_FAILURE);
75
76
}std::cout << " server started" << " \n " ;
76
77
while ( server.IsServerRunning () ) {
77
- sleep ( 1 );
78
+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ) );
78
79
}
79
80
std::cout << " server exit...\n " ;
80
81
exit (EXIT_SUCCESS);
Original file line number Diff line number Diff line change @@ -26,20 +26,12 @@ elseif(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux")
26
26
add_definitions (-Wall -Werror -Wextra -Wpedantic )
27
27
endif ()
28
28
29
- if (WIN32 )
30
- set (TEST_FILES
31
- buffer_test.cpp
32
- tcp_test.cpp
33
- udp_test.cpp
34
- )
35
- elseif (APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux" )
36
- set (TEST_FILES
37
- buffer_test.cpp
38
- tcp_test.cpp
39
- udp_test.cpp
40
- ipc_test.cpp
41
- )
42
- endif ()
29
+ set (TEST_FILES
30
+ buffer_test.cpp
31
+ tcp_test.cpp
32
+ udp_test.cpp
33
+ ipc_test.cpp
34
+ )
43
35
44
36
enable_testing ()
45
37
find_package (GTest CONFIG REQUIRED )
Original file line number Diff line number Diff line change 7
7
#include " asock/asock_ipc_server.hpp"
8
8
9
9
#define DEFAULT_PACKET_SIZE 1024
10
-
10
+ // NOTE: Not implemented on Windows.
11
11
// This file is created in the current directory and automatically deleted.
12
12
#define TEST_IPC_PATH " asock.test.ipc"
13
13
You can’t perform that action at this time.
0 commit comments