这次又要到Linux下做了,把之前的自己写的socket类改成了通用的,当然目前的结构还是太简单了,很多以前封装的不符合面向对象的函数又被我砍掉了,慢慢完善吧~~
Socket.h
1 #if !defined(__DZLIB_SOCKET_H__)
2 #define __DZLIB_SOCKET_H__
3
4 #if defined(WIN32)
5 # include
6 #else
7 # include
8 # include
9 #endif
10
11 // -----------------------------------------------------------------------------
12 // namespace DZLIB -------------------------------------------------------------
13 namespace DZLIB
14 {
15
16
17 // -----------------------------------------------------------------------------
18 // class SocketEnvironment -----------------------------------------------------
19 #if defined(WIN32)
20 class SocketEnvironment
21 {
22 public:
23 // constructors and destructors
24 SocketEnvironment();
25 ~SocketEnvironment();
26
27 // static funcs
28 static bool Init();
29 static bool Exit();
30 };
31 #endif
32
33
34 // -----------------------------------------------------------------------------
35 // class SocketAddr ------------------------------------------------------------
36 class SocketAddr
37 {
38 friend class TcpSocket;
39 friend class UdpSocket;
40