aboutsummaryrefslogtreecommitdiff
path: root/src/socket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/socket.cpp')
-rw-r--r--src/socket.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 1e9a2f9..aea66f8 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -16,6 +16,7 @@
16#include <fcntl.h> 16#include <fcntl.h>
17#include "socket.h" 17#include "socket.h"
18#include "osx_compatibility.h" 18#include "osx_compatibility.h"
19#include "win32_compatibility.h"
19 20
20#ifndef WIN32 21#ifndef WIN32
21 #include <sys/socket.h> 22 #include <sys/socket.h>
@@ -194,11 +195,7 @@ void Bu::Socket::read()
194 195
195size_t Bu::Socket::read( void *pBuf, size_t nBytes ) 196size_t Bu::Socket::read( void *pBuf, size_t nBytes )
196{ 197{
197#ifndef WIN32
198 int nRead = TEMP_FAILURE_RETRY( ::read( nSocket, pBuf, nBytes ) ); 198 int nRead = TEMP_FAILURE_RETRY( ::read( nSocket, pBuf, nBytes ) );
199#else
200 int nRead = ::read( nSocket, pBuf, nBytes );
201#endif
202 if( nRead < 0 ) 199 if( nRead < 0 )
203 { 200 {
204 throw SocketException( SocketException::cRead, strerror(errno) ); 201 throw SocketException( SocketException::cRead, strerror(errno) );
@@ -209,7 +206,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes )
209size_t Bu::Socket::read( void *pBuf, size_t nBytes, 206size_t Bu::Socket::read( void *pBuf, size_t nBytes,
210 uint32_t nSec, uint32_t nUSec ) 207 uint32_t nSec, uint32_t nUSec )
211{ 208{
212 struct timeval tv, nt, ct; 209 struct timeval tv;
213 size_t nRead = 0; 210 size_t nRead = 0;
214 211
215 fd_set rfds; 212 fd_set rfds;
@@ -217,6 +214,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes,
217 FD_SET(nSocket, &rfds); 214 FD_SET(nSocket, &rfds);
218 215
219#ifndef WIN32 216#ifndef WIN32
217 struct timeval nt, ct;
220 gettimeofday( &nt, NULL ); 218 gettimeofday( &nt, NULL );
221 nt.tv_sec += nSec; 219 nt.tv_sec += nSec;
222 nt.tv_usec += nUSec; 220 nt.tv_usec += nUSec;
@@ -251,11 +249,7 @@ size_t Bu::Socket::read( void *pBuf, size_t nBytes,
251 249
252size_t Bu::Socket::write( const void *pBuf, size_t nBytes ) 250size_t Bu::Socket::write( const void *pBuf, size_t nBytes )
253{ 251{
254#ifndef WIN32
255 int nWrote = TEMP_FAILURE_RETRY( ::write( nSocket, pBuf, nBytes ) ); 252 int nWrote = TEMP_FAILURE_RETRY( ::write( nSocket, pBuf, nBytes ) );
256#else
257 int nWrote = ::write( nSocket, pBuf, nBytes );
258#endif
259 if( nWrote < 0 ) 253 if( nWrote < 0 )
260 { 254 {
261 if( errno == EAGAIN ) return 0; 255 if( errno == EAGAIN ) return 0;
@@ -266,7 +260,7 @@ size_t Bu::Socket::write( const void *pBuf, size_t nBytes )
266 260
267size_t Bu::Socket::write( const void *pBuf, size_t nBytes, uint32_t nSec, uint32_t nUSec ) 261size_t Bu::Socket::write( const void *pBuf, size_t nBytes, uint32_t nSec, uint32_t nUSec )
268{ 262{
269 struct timeval tv, nt, ct; 263 struct timeval tv;
270 size_t nWrote = 0; 264 size_t nWrote = 0;
271 265
272 fd_set wfds; 266 fd_set wfds;
@@ -274,6 +268,7 @@ size_t Bu::Socket::write( const void *pBuf, size_t nBytes, uint32_t nSec, uint32
274 FD_SET(nSocket, &wfds); 268 FD_SET(nSocket, &wfds);
275 269
276#ifndef WIN32 270#ifndef WIN32
271 struct timeval nt, ct;
277 gettimeofday( &nt, NULL ); 272 gettimeofday( &nt, NULL );
278 nt.tv_sec += nSec; 273 nt.tv_sec += nSec;
279 nt.tv_usec += nUSec; 274 nt.tv_usec += nUSec;
@@ -421,9 +416,9 @@ bool Bu::Socket::isOpen()
421 return bActive; 416 return bActive;
422} 417}
423 418
424#ifdef WIN32 419//#ifdef WIN32
425 typedef int socklen_t; 420// typedef int socklen_t;
426#endif 421//#endif
427 422
428void Bu::Socket::setAddress() 423void Bu::Socket::setAddress()
429{ 424{