diff options
-rw-r--r-- | src/tcpsocket.cpp | 17 | ||||
-rw-r--r-- | src/tcpsocket.h | 20 |
2 files changed, 28 insertions, 9 deletions
diff --git a/src/tcpsocket.cpp b/src/tcpsocket.cpp index 399ec44..b9b215c 100644 --- a/src/tcpsocket.cpp +++ b/src/tcpsocket.cpp | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | namespace Bu { subExceptionDef( TcpSocketException ) } | 32 | namespace Bu { subExceptionDef( TcpSocketException ) } |
33 | 33 | ||
34 | Bu::TcpSocket::TcpSocket( int nTcpSocket ) : | 34 | Bu::TcpSocket::TcpSocket( handle nTcpSocket ) : |
35 | nTcpSocket( nTcpSocket ), | 35 | nTcpSocket( nTcpSocket ), |
36 | bActive( true ), | 36 | bActive( true ), |
37 | bBlocking( true ) | 37 | bBlocking( true ) |
@@ -443,11 +443,24 @@ Bu::String Bu::TcpSocket::getAddress() const | |||
443 | return sAddress; | 443 | return sAddress; |
444 | } | 444 | } |
445 | 445 | ||
446 | Bu::TcpSocket::operator int() const | 446 | Bu::TcpSocket::operator Bu::TcpSocket::handle() const |
447 | { | 447 | { |
448 | return nTcpSocket; | 448 | return nTcpSocket; |
449 | } | 449 | } |
450 | 450 | ||
451 | Bu::TcpSocket::handle Bu::TcpSocket::getHandle() const | ||
452 | { | ||
453 | return nTcpSocket; | ||
454 | } | ||
455 | |||
456 | Bu::TcpSocket::handle Bu::TcpSocket::takeHandle() | ||
457 | { | ||
458 | handle nRet = nTcpSocket; | ||
459 | bActive = false; | ||
460 | nTcpSocket = 0; | ||
461 | return nRet; | ||
462 | } | ||
463 | |||
451 | Bu::size Bu::TcpSocket::getSize() const | 464 | Bu::size Bu::TcpSocket::getSize() const |
452 | { | 465 | { |
453 | throw UnsupportedException(); | 466 | throw UnsupportedException(); |
diff --git a/src/tcpsocket.h b/src/tcpsocket.h index dbaaa5e..52218bd 100644 --- a/src/tcpsocket.h +++ b/src/tcpsocket.h | |||
@@ -60,7 +60,13 @@ namespace Bu | |||
60 | class TcpSocket : public Stream | 60 | class TcpSocket : public Stream |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | TcpSocket( int nTcpSocket ); | 63 | #ifdef WIN32 |
64 | typedef unsigned int handle; | ||
65 | #else | ||
66 | typedef int handle; | ||
67 | #endif | ||
68 | |||
69 | TcpSocket( handle nTcpSocket ); | ||
64 | TcpSocket( const String &sAddr, int nPort, int nTimeout=30, | 70 | TcpSocket( const String &sAddr, int nPort, int nTimeout=30, |
65 | bool bBlocking=true ); | 71 | bool bBlocking=true ); |
66 | virtual ~TcpSocket(); | 72 | virtual ~TcpSocket(); |
@@ -96,7 +102,10 @@ namespace Bu | |||
96 | virtual void setSize( size iSize ); | 102 | virtual void setSize( size iSize ); |
97 | 103 | ||
98 | Bu::String getAddress() const; | 104 | Bu::String getAddress() const; |
99 | operator int() const; | 105 | operator handle() const; |
106 | |||
107 | handle getHandle() const; | ||
108 | handle takeHandle(); | ||
100 | 109 | ||
101 | virtual size getSize() const; | 110 | virtual size getSize() const; |
102 | virtual size getBlockSize() const; | 111 | virtual size getBlockSize() const; |
@@ -105,11 +114,8 @@ namespace Bu | |||
105 | private: | 114 | private: |
106 | void setAddress(); | 115 | void setAddress(); |
107 | 116 | ||
108 | #ifdef WIN32 | 117 | handle nTcpSocket; |
109 | unsigned int nTcpSocket; | 118 | |
110 | #else | ||
111 | int nTcpSocket; | ||
112 | #endif | ||
113 | bool bActive; | 119 | bool bActive; |
114 | bool bBlocking; | 120 | bool bBlocking; |
115 | String sReadBuf; | 121 | String sReadBuf; |