Skip to content

Commit 68a57ad

Browse files
committed
modify out interface.
1 parent a2a0c82 commit 68a57ad

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

include/CppDefine.h

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ namespace cppnet {
3434
EVENT_ERROR_CLOSED = 0x0400,
3535
EVENT_ERROR_DONE = 0x0800,
3636
EVENT_ERROR_INVALID_HANDLE = 0x0001,
37+
EVENT_ERROR_FAILED = 0x0002,
38+
EVENT_ERROR_CONNECT_BREAK = 0x0003,
3739
};
3840
}
3941

include/CppNet.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define HEADER_INCLUDE_CPPNET
33

44
#include "CppDefine.h"
5+
#include "Socket.h"
56

67
namespace cppnet {
78

@@ -23,11 +24,11 @@ namespace cppnet {
2324

2425
//server
2526
void SetAcceptCallback(const connection_call_back& func);
26-
bool ListenAndAccept(int16_t port, std::string ip);
27+
bool ListenAndAccept(int16_t port, std::string ip, uint32_t listen_num);
2728

2829
//client
2930
void SetConnectionCallback(const connection_call_back& func);
30-
Handle Connection(int16_t port, std::string ip, char* buf, int32_t buf_len);
31+
Handle Connection(int16_t port, std::string ip, const char* buf, int32_t buf_len);
3132
Handle Connection(int16_t port, std::string ip);
3233
}
3334

include/Socket.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@ namespace cppnet {
88
// post sync read event.
99
int16_t SyncRead(const Handle& handle);
1010
// post sync write event.
11-
int16_t SyncWrite(const Handle& handle, char* src, int32_t len);
11+
int16_t SyncWrite(const Handle& handle, const char* src, int32_t len);
1212

1313
// post sync read event with time out
1414
int16_t SyncRead(const Handle& handle, int32_t interval);
1515
// post sync write event with time out
16-
int16_t SyncWrite(const Handle& handle, int32_t interval, char* src, int32_t len);
16+
int16_t SyncWrite(const Handle& handle, int32_t interval, const char* src, int32_t len);
1717

1818
// post a sync task to io thread
1919
int16_t PostTask(std::function<void(void)>& func);
2020
#ifndef __linux__
2121
// sync connection.
2222
int16_t SyncConnection(const std::string& ip, int16_t port, char* buf, int32_t buf_len);
23-
#else
24-
int16_t SyncConnection(const std::string& ip, int16_t port);
2523
#endif
26-
int16_t SyncDisconnection();
24+
int16_t SyncConnection(const std::string& ip, int16_t port);
25+
26+
int16_t SyncDisconnection(const Handle& handle);
2727

28+
int16_t Close(const Handle& handle);
2829
}
2930

3031
#endif

include/Type.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef HEADER_COMMON_COMMONTYPE
2-
#define HEADER_COMMON_COMMONTYPE
1+
#ifndef HEADER_INCLUDE_TYPE
2+
#define HEADER_INCLUDE_TYPE
33

44
namespace cppnet {
55

0 commit comments

Comments
 (0)