diff options
author | chai <chaifix@163.com> | 2018-10-19 08:36:44 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-19 08:36:44 +0800 |
commit | 7d5f055547e70fa93ee9ac944e62f8d657b9dc55 (patch) | |
tree | 081782a1541854db4b8eb69c4b43081f52711286 /src/libjin/Net/je_socket.h | |
parent | 02dd1f38008594048f0e28bad01e7c6d18844198 (diff) |
*修改文件名
Diffstat (limited to 'src/libjin/Net/je_socket.h')
-rw-r--r-- | src/libjin/Net/je_socket.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/libjin/Net/je_socket.h b/src/libjin/Net/je_socket.h new file mode 100644 index 0000000..ab6a561 --- /dev/null +++ b/src/libjin/Net/je_socket.h @@ -0,0 +1,62 @@ +#ifndef __LIBJIN_NET_SOCKET_H +#define __LIBJIN_NET_SOCKET_H +#include "../core/je_configuration.h" +#if LIBJIN_MODULES_NET + +#include "../3rdparty/tekcos/tekcos.h" + +namespace jin +{ + namespace net + { + + enum SocketType + { + TCP, + UDP + }; + + struct SocketInformation + { + unsigned int address; + unsigned short port; + SocketType type; + }; + + class Socket + { + public: + Socket() {}; + Socket(const Socket& socket); + Socket(const SocketInformation& socketInformation); + Socket(SocketType type, unsigned short port); + Socket(SocketType type, unsigned int address, unsigned short port); + Socket(SocketType type, const char* address, unsigned short port); + ~Socket(); + void configureBlocking(bool bocking); + Socket* accept(); + int receive(char* buffer, int size); + int send(char* buffer, int size); + void sendTo(char* buffer, int size, unsigned int address, unsigned int port); + int receiveFrom(char* buffer, int size, unsigned int address, unsigned int port); + void close(); + + protected: + #if LIBJIN_NET_TEKCOS + Socket(const tk_TCPsocket& tcpHandle); + Socket(const tk_UDPsocket& udpHandle); + union + { + tk_TCPsocket tcpHandle; + tk_UDPsocket udpHandle; + } handle; + #endif + SocketType type; + + }; + + } // namespace net +} // namespace jin + +#endif // LIBJIN_MODULES_NET +#endif // __LIBJIN_NET_SOCKET_H |