summaryrefslogtreecommitdiff
path: root/src/tcpsocket.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 18:09:04 +0000
commit393f1b414746a7f1977971dd7659dd2b47092b11 (patch)
tree81d0ca1ee70ab86a7d79c1991abe5c387b655fb2 /src/tcpsocket.cpp
parentc259f95bd0e58b247940a339bb9b4b401b4e9438 (diff)
parent7e25a863325dc3e9762397e700030969e093b087 (diff)
downloadlibbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.gz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.bz2
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.xz
libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.zip
Wow! Merged the branch, streams are updated, and there's no more FString, run
the fixstrings.sh script in the support directory to (hopefully) automatically update your projects.
Diffstat (limited to 'src/tcpsocket.cpp')
-rw-r--r--src/tcpsocket.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/tcpsocket.cpp b/src/tcpsocket.cpp
index bbd9cf5..52dfc5c 100644
--- a/src/tcpsocket.cpp
+++ b/src/tcpsocket.cpp
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2010 Xagasoft, All rights reserved. 2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 * 3 *
4 * This file is part of the libbu++ library and is released under the 4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
@@ -42,7 +42,7 @@ Bu::TcpSocket::TcpSocket( int nTcpSocket ) :
42 setAddress(); 42 setAddress();
43} 43}
44 44
45Bu::TcpSocket::TcpSocket( const Bu::FString &sAddr, int nPort, int nTimeout, 45Bu::TcpSocket::TcpSocket( const Bu::String &sAddr, int nPort, int nTimeout,
46 bool bBlocking ) : 46 bool bBlocking ) :
47 nTcpSocket( 0 ), 47 nTcpSocket( 0 ),
48 bActive( false ), 48 bActive( false ),
@@ -149,7 +149,7 @@ void Bu::TcpSocket::close()
149 bActive = false; 149 bActive = false;
150} 150}
151 151
152size_t Bu::TcpSocket::read( void *pBuf, size_t nBytes ) 152Bu::size Bu::TcpSocket::read( void *pBuf, Bu::size nBytes )
153{ 153{
154 fd_set rfds; 154 fd_set rfds;
155 FD_ZERO(&rfds); 155 FD_ZERO(&rfds);
@@ -195,11 +195,11 @@ size_t Bu::TcpSocket::read( void *pBuf, size_t nBytes )
195 return 0; 195 return 0;
196} 196}
197 197
198size_t Bu::TcpSocket::read( void *pBuf, size_t nBytes, 198Bu::size Bu::TcpSocket::read( void *pBuf, Bu::size nBytes,
199 uint32_t nSec, uint32_t nUSec ) 199 uint32_t nSec, uint32_t nUSec )
200{ 200{
201 struct timeval tv; 201 struct timeval tv;
202 size_t nRead = 0; 202 Bu::size nRead = 0;
203 203
204 fd_set rfds; 204 fd_set rfds;
205 FD_ZERO(&rfds); 205 FD_ZERO(&rfds);
@@ -239,7 +239,7 @@ size_t Bu::TcpSocket::read( void *pBuf, size_t nBytes,
239 return nRead; 239 return nRead;
240} 240}
241 241
242size_t Bu::TcpSocket::write( const void *pBuf, size_t nBytes ) 242Bu::size Bu::TcpSocket::write( const void *pBuf, Bu::size nBytes )
243{ 243{
244//#ifdef WIN32 244//#ifdef WIN32
245 int nWrote = TEMP_FAILURE_RETRY( 245 int nWrote = TEMP_FAILURE_RETRY(
@@ -261,10 +261,10 @@ size_t Bu::TcpSocket::write( const void *pBuf, size_t nBytes )
261 return nWrote; 261 return nWrote;
262} 262}
263 263
264size_t Bu::TcpSocket::write( const void *pBuf, size_t nBytes, uint32_t nSec, uint32_t nUSec ) 264Bu::size Bu::TcpSocket::write( const void *pBuf, Bu::size nBytes, uint32_t nSec, uint32_t nUSec )
265{ 265{
266 struct timeval tv; 266 struct timeval tv;
267 size_t nWrote = 0; 267 Bu::size nWrote = 0;
268 268
269 fd_set wfds; 269 fd_set wfds;
270 FD_ZERO(&wfds); 270 FD_ZERO(&wfds);
@@ -304,22 +304,22 @@ size_t Bu::TcpSocket::write( const void *pBuf, size_t nBytes, uint32_t nSec, uin
304 return nWrote; 304 return nWrote;
305} 305}
306 306
307long Bu::TcpSocket::tell() 307Bu::size Bu::TcpSocket::tell()
308{ 308{
309 throw UnsupportedException(); 309 throw UnsupportedException();
310} 310}
311 311
312void Bu::TcpSocket::seek( long ) 312void Bu::TcpSocket::seek( Bu::size )
313{ 313{
314 throw UnsupportedException(); 314 throw UnsupportedException();
315} 315}
316 316
317void Bu::TcpSocket::setPos( long ) 317void Bu::TcpSocket::setPos( Bu::size )
318{ 318{
319 throw UnsupportedException(); 319 throw UnsupportedException();
320} 320}
321 321
322void Bu::TcpSocket::setPosEnd( long ) 322void Bu::TcpSocket::setPosEnd( Bu::size )
323{ 323{
324 throw UnsupportedException(); 324 throw UnsupportedException();
325} 325}
@@ -401,7 +401,7 @@ void Bu::TcpSocket::setBlocking( bool bBlocking )
401 fcntl( nTcpSocket, F_SETFL, fcntl( nTcpSocket, F_GETFL, 0 ) | O_NONBLOCK ); 401 fcntl( nTcpSocket, F_SETFL, fcntl( nTcpSocket, F_GETFL, 0 ) | O_NONBLOCK );
402 } 402 }
403#else 403#else
404 u_long iMode; 404 u_Bu::size iMode;
405 if( bBlocking ) 405 if( bBlocking )
406 iMode = 0; 406 iMode = 0;
407 else 407 else
@@ -416,7 +416,7 @@ void Bu::TcpSocket::setBlocking( bool bBlocking )
416#endif 416#endif
417} 417}
418 418
419void Bu::TcpSocket::setSize( long ) 419void Bu::TcpSocket::setSize( Bu::size )
420{ 420{
421} 421}
422 422
@@ -438,7 +438,7 @@ void Bu::TcpSocket::setAddress()
438 sAddress = bu_inet_ntoa( addr.sin_addr ); 438 sAddress = bu_inet_ntoa( addr.sin_addr );
439} 439}
440 440
441Bu::FString Bu::TcpSocket::getAddress() const 441Bu::String Bu::TcpSocket::getAddress() const
442{ 442{
443 return sAddress; 443 return sAddress;
444} 444}
@@ -448,3 +448,18 @@ Bu::TcpSocket::operator int() const
448 return nTcpSocket; 448 return nTcpSocket;
449} 449}
450 450
451Bu::size Bu::TcpSocket::getSize() const
452{
453 throw UnsupportedException();
454}
455
456Bu::size Bu::TcpSocket::getBlockSize() const
457{
458 return 1500; //TODO: Fix this, it's stupid.
459}
460
461Bu::String Bu::TcpSocket::getLocation() const
462{
463 return getAddress();
464}
465