diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-07-25 17:25:28 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-07-25 17:25:28 +0000 |
commit | d3a6d910f96d1509b17165b635663b608681b89a (patch) | |
tree | 923b1e0f783d5b710f82664591812895cb9dbba3 /src/tcpsocket.h | |
parent | d0d86b9ae6a86fec59f69c76352c640e759bd4a1 (diff) | |
download | libbu++-d3a6d910f96d1509b17165b635663b608681b89a.tar.gz libbu++-d3a6d910f96d1509b17165b635663b608681b89a.tar.bz2 libbu++-d3a6d910f96d1509b17165b635663b608681b89a.tar.xz libbu++-d3a6d910f96d1509b17165b635663b608681b89a.zip |
In theory, after constructing a TcpSocket object, you can now take the
operating system socket handle away and use it yourself, after doing so, the
TcpSocket will not close the socket when it exits, or be able to effect it ever
again.
Diffstat (limited to 'src/tcpsocket.h')
-rw-r--r-- | src/tcpsocket.h | 20 |
1 files changed, 13 insertions, 7 deletions
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; |