00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00046
#ifndef CCXX_SOCKET_H_
00047
#define CCXX_SOCKET_H_
00048
00049
#ifndef CCXX_ADDRESS_H_
00050
#include <cc++/address.h>
00051
#endif
00052
00053
#if defined(WIN32) && !defined(__CYGWIN32__)
00054
#include <io.h>
00055
#define _IOLEN64 (unsigned)
00056
#define _IORET64 (ssize_t)
00057
#define TIMEOUT_INF ~((timeout_t) 0)
00058
typedef int socklen_t;
00059
#else
00060 #define INVALID_SOCKET -1
00061 typedef int SOCKET;
00062
#endif
00063
00064
#ifndef _IOLEN64
00065
#define _IOLEN64
00066
#endif
00067
00068
#ifndef _IORET64
00069
#define _IORET64
00070
#endif
00071
00072
#ifndef MSG_DONTWAIT
00073 #define MSG_DONTWAIT 0
00074
#endif
00075
00076
#ifdef CCXX_NAMESPACES
00077
namespace ost {
00078
#endif
00079
00083
typedef unsigned short tpport_t;
00084
00102 class __EXPORT Socket
00103 {
00104
public:
00105 enum Family
00106 {
00107
#ifdef CCXX_IPV6
00108
IPV6 = AF_INET6,
00109
#endif
00110
IPV4 = AF_INET
00111 };
00112
00113 typedef enum Family Family;
00114
00115 enum Error
00116 {
00117 errSuccess = 0,
00118 errCreateFailed,
00119 errCopyFailed,
00120 errInput,
00121 errInputInterrupt,
00122 errResourceFailure,
00123 errOutput,
00124 errOutputInterrupt,
00125 errNotConnected,
00126 errConnectRefused,
00127 errConnectRejected,
00128 errConnectTimeout,
00129 errConnectFailed,
00130 errConnectInvalid,
00131 errConnectBusy,
00132 errConnectNoRoute,
00133 errBindingFailed,
00134 errBroadcastDenied,
00135 errRoutingDenied,
00136 errKeepaliveDenied,
00137 errServiceDenied,
00138 errServiceUnavailable,
00139 errMulticastDisabled,
00140 errTimeout,
00141 errNoDelay,
00142 errExtended,
00143 errLookupFail,
00144 errSearchErr,
00145 errInvalidValue
00146 };
00147
00148 typedef enum Error Error;
00149
00150 enum Tos
00151 {
00152 tosLowDelay = 0,
00153 tosThroughput,
00154 tosReliability,
00155 tosMinCost,
00156 tosInvalid
00157 };
00158 typedef enum Tos Tos;
00159
00160 enum Pending
00161 {
00162 pendingInput,
00163 pendingOutput,
00164 pendingError
00165 };
00166 typedef enum Pending Pending;
00167
00168
protected:
00169 enum State
00170 {
00171 INITIAL,
00172 AVAILABLE,
00173 BOUND,
00174 CONNECTED,
00175 CONNECTING,
00176 STREAM
00177 };
00178 typedef enum State State;
00179
00180
private:
00181
00182
mutable Error errid;
00183
mutable const char *errstr;
00184
mutable long syserr;
00185
00186
void setSocket(
void);
00187
friend SOCKET dupSocket(SOCKET s,
Socket::State state);
00188
00189
protected:
00190 static Mutex mutex;
00191
00192
mutable struct
00193
{
00194 bool thrown: 1;
00195 bool broadcast: 1;
00196 bool route: 1;
00197 bool keepalive: 1;
00198 bool loopback: 1;
00199 bool multicast: 1;
00200 bool completion: 1;
00201 bool linger: 1;
00202 unsigned ttl: 8;
00203 } flags;
00204
00210 SOCKET volatile so;
00211 State volatile state;
00212
00221
Error error(
Error error,
char *err = NULL,
long systemError = 0)
const;
00222
00229 inline void error(
char *err)
const
00230
{error(errExtended, err);};
00231
00238 inline void setError(
bool enable)
00239 {flags.thrown = !enable;};
00240
00246
void endSocket(
void);
00247
00253 Error connectError(
void);
00254
00258 Error sendLimit(
int limit = 2048);
00259
00263 Error receiveLimit(
int limit = 1);
00264
00271 Error sendTimeout(
timeout_t to);
00272
00276 Error receiveTimeout(
timeout_t to);
00277
00284 Error sendBuffer(
unsigned bufsize);
00285
00292 Error receiveBuffer(
unsigned bufsize);
00293
00300 Error bufferSize(
unsigned bufsize);
00301
00310 Error setBroadcast(
bool enable);
00311
00322 Error setMulticastByFamily(
bool enable, Family family = IPV4);
00323
00331 Error setLoopbackByFamily(
bool enable, Family family = IPV4);
00332
00339 Error setTimeToLiveByFamily(
unsigned char ttl, Family fam = IPV4);
00340
00347 Error join(
const IPV4Multicast &ia);
00348
#ifdef CCXX_IPV6
00349
Error join(
const IPV6Multicast &ia);
00350
#endif
00351
00358 Error drop(
const IPV4Multicast &ia);
00359
#ifdef CCXX_IPV6
00360
Error drop(
const IPV6Multicast &ia);
00361
#endif
00362
00370 Error setRouting(
bool enable);
00371
00372
00379 Error setNoDelay(
bool enable);
00380
00392 Socket(
int domain,
int type,
int protocol = 0);
00393
00401 Socket(SOCKET fd);
00402
00406 Socket();
00407
00415 Socket(
const Socket &source);
00416
00426 ssize_t readLine(
char *buf, size_t len,
timeout_t timeout = 0);
00427
00439
virtual ssize_t readData(
void * buf,size_t len,
char separator=0,
timeout_t t=0);
00440
00449
virtual ssize_t writeData(
const void* buf,size_t len,
timeout_t t=0);
00450
00451
00452
public:
00460
virtual ~Socket();
00461
00468
static bool check(Family fam);
00469
00473 Socket &operator=(
const Socket &from);
00474
00484
IPV4Host getIPV4Sender(
tpport_t *port = NULL)
const;
00485
00486 inline IPV4Host getSender(
tpport_t *port = NULL)
const
00487
{
return getIPV4Sender(port);}
00488
00489
#ifdef CCXX_IPV6
00490
IPV6Host getIPV6Sender(
tpport_t *port = NULL)
const;
00491
#endif
00492
00502
IPV4Host getIPV4Peer(
tpport_t *port = NULL)
const;
00503
00504 inline IPV4Host getPeer(
tpport_t *port)
const
00505
{
return getIPV4Peer(port);}
00506
00507
#ifdef CCXX_IPV6
00508
IPV6Host getIPV6Peer(
tpport_t *port = NULL)
const;
00509
#endif
00510
00518
IPV4Host getIPV4Local(
tpport_t *port = NULL)
const;
00519
00520 inline IPV4Host getLocal(
tpport_t *port)
const
00521
{
return getIPV4Local(port);}
00522
00523
#ifdef CCXX_IPV6
00524
IPV6Host getIPV6Local(
tpport_t *port = NULL)
const;
00525
#endif
00526
00554
IPV4Host getIPV4NAT(
tpport_t *port = NULL)
const;
00555
00556 inline IPV4Host getNAT(
tpport_t *port)
const
00557
{
return getIPV4NAT(port);}
00558
00559
#ifdef CCXX_IPV6
00560
IPV6Host getIPV6NAT(
tpport_t *port = NULL)
const;
00561
#endif
00562
00573
void setCompletion(
bool immediate);
00574
00580 Error setLinger(
bool linger);
00581
00589 Error setKeepAlive(
bool enable);
00590
00599 Error setTypeOfService(Tos service);
00600
00609
bool isConnected(
void) const;
00610
00618
bool isActive(
void) const;
00619
00624
bool operator!() const;
00625
00632 inline
bool isBroadcast(
void)
const
00633
{
return flags.broadcast;};
00634
00640 inline bool isRouted(
void)
const
00641
{
return flags.route;};
00642
00649 inline Error getErrorNumber(
void)
const {
return errid;}
00650
00657 inline const char *getErrorString(
void)
const {
return errstr;}
00658
00659 inline long getSystemError(
void)
const {
return syserr;}
00660
00661
const char *getSystemErrorString(
void) const;
00662
00672 virtual
bool isPending(Pending pend,
timeout_t timeout = TIMEOUT_INF);
00673 };
00674
00707 class __EXPORT
UDPSocket : public Socket
00708 {
00709
private:
00710
inline Error setKeepAlive(
bool enable)
00711 {
return Socket::setKeepAlive(enable);};
00712
00713
protected:
00714
#ifdef CCXX_IPV6
00715
union
00716
{
00717 struct sockaddr_in6 ipv6;
00718 struct sockaddr_in ipv4;
00719 } peer;
00720
#else
00721
union
00722
{
00723
struct sockaddr_in ipv4;
00724 } peer;
00725
#endif
00726
00727 Family family;
00728
00729
public:
00733
UDPSocket(Family family = IPV4);
00734
00738
UDPSocket(
const char *name, Family family = IPV4);
00739
00749
UDPSocket(
const IPV4Address &bind,
tpport_t port);
00750
#ifdef CCXX_IPV6
00751
UDPSocket(
const IPV6Address &bind,
tpport_t port);
00752
#endif
00753
00757
virtual ~
UDPSocket();
00758
00762 inline Error setLoopback(
bool enable)
00763 {
return Socket::setLoopbackByFamily(enable, family);}
00764
00768 inline Error setMulticast(
bool enable)
00769 {
return Socket::setMulticastByFamily(enable, family);}
00770
00774 inline Error setTimeToLive(
char ttl)
00775 {
return Socket::setTimeToLiveByFamily(ttl, family);}
00776
00784
void setPeer(
const IPV4Host &host,
tpport_t port);
00785
void connect(
const IPV4Host &host,
tpport_t port);
00786
#ifdef CCXX_IPV6
00787
void setPeer(
const IPV6Host &host,
tpport_t port);
00788
void connect(
const IPV6Host &host,
tpport_t port);
00789
#endif
00790
00798
Socket::Error getInterfaceIndex(
const char *ethX,
int& InterfaceIndex);
00799
00808
Socket::Error join(
const IPV4Multicast &ia,
int InterfaceIndex);
00809
00810
00818 ssize_t send(
const void *buf, size_t len);
00819
00828 ssize_t receive(
void *buf, size_t len,
bool reply =
false);
00829
00838
IPV4Host getIPV4Peer(
tpport_t *port = NULL)
const;
00839 inline IPV4Host getPeer(
tpport_t *port = NULL)
const
00840
{
return getIPV4Peer(port);}
00841
00842
#ifdef CCXX_IPV6
00843
IPV6Host getIPV6Peer(
tpport_t *port = NULL)
const;
00844
#endif
00845
00853 inline ssize_t peek(
void *buf, size_t len)
00854 {
return _IORET64 ::recv(so, (
char *)buf, _IOLEN64 len, MSG_PEEK);};
00855
00859
void setPeer(
const char *service);
00860
void connect(
const char *service);
00861
00866 Error disconnect(
void);
00867 };
00868
00869
00878 class __EXPORT UDPBroadcast :
public UDPSocket
00879 {
00880
private:
00881
void setPeer(
const IPV4Host &ia,
tpport_t port) {};
00882
00883 Error setBroadcast(
bool enable)
00884 {
return Socket::setBroadcast(enable);};
00885
00886
public:
00893 UDPBroadcast(
const IPV4Address &ia,
tpport_t port);
00894
00901
void setPeer(
const IPV4Broadcast &subnet,
tpport_t port);
00902 };
00903
00912 class __EXPORT UDPTransmit :
protected UDPSocket
00913 {
00914
private:
00922 Error cConnect(
const IPV4Address &ia,
tpport_t port);
00923
00924
protected:
00928 UDPTransmit(Family family = IPV4);
00929
00941 UDPTransmit(
const IPV4Address &bind,
tpport_t port = 5005);
00942
#ifdef CCXX_IPV6
00943
UDPTransmit(
const IPV6Address &bind,
tpport_t port = 5005);
00944
#endif
00945
00955 Error connect(
const IPV4Host &host,
tpport_t port);
00956
#ifdef CCXX_IPV6
00957
Error connect(
const IPV6Address &host,
tpport_t port);
00958
#endif
00959
00969 Error connect(
const IPV4Broadcast &subnet,
tpport_t port);
00970
00978 Error connect(
const IPV4Multicast &mgroup,
tpport_t port);
00979
#ifdef CCXX_IPV6
00980
Error connect(
const IPV6Multicast &mgroup,
tpport_t port);
00981
#endif
00982
00990 inline ssize_t send(
const void *buf, size_t len)
00991 {
return _IORET64 ::send(so, (
const char *)buf, _IOLEN64 len, 0);}
00992
00996 inline void endTransmitter(
void)
00997 {Socket::endSocket();}
00998
00999
01000
01001
01002
01003
01004 inline SOCKET getTransmitter(
void)
01005 {
return so;};
01006
01007 inline Error setMulticast(
bool enable)
01008 {
return Socket::setMulticastByFamily(enable, family);}
01009
01010 inline Error setTimeToLive(
unsigned char ttl)
01011 {
return Socket::setTimeToLiveByFamily(ttl, family);};
01012
01013
public:
01023 inline ssize_t transmit(
const char *buffer, size_t len)
01024 {
return _IORET64 ::send(so, buffer, _IOLEN64 len,
MSG_DONTWAIT);}
01025
01032 inline bool isOutputReady(
unsigned long timeout = 0l)
01033 {
return Socket::isPending(Socket::pendingOutput, timeout);};
01034
01035
01036 inline Error setRouting(
bool enable)
01037 {
return Socket::setRouting(enable);};
01038
01039 inline Error setTypeOfService(Tos tos)
01040 {
return Socket::setTypeOfService(tos);};
01041
01042 inline Error setBroadcast(
bool enable)
01043 {
return Socket::setBroadcast(enable);};
01044 };
01045
01054 class __EXPORT UDPReceive :
protected UDPSocket
01055 {
01056
protected:
01067 UDPReceive(
const IPV4Address &bind,
tpport_t port);
01068
#ifdef CCXX_IPV6
01069
UDPReceive(
const IPV6Address &bind,
tpport_t port);
01070
#endif
01071
01081 Error connect(
const IPV4Host &host,
tpport_t port);
01082
#ifdef CCXX_IPV6
01083
Error connect(
const IPV6Host &host,
tpport_t port);
01084
#endif
01085
01092 bool isPendingReceive(
timeout_t timeout)
01093 {
return Socket::isPending(Socket::pendingInput, timeout);};
01094
01098 inline void endReceiver(
void)
01099 {Socket::endSocket();}
01100
01101 inline SOCKET getReceiver(
void)
const
01102
{
return so;};
01103
01104 inline Error setRouting(
bool enable)
01105 {
return Socket::setRouting(enable);}
01106
01107 inline Error setMulticast(
bool enable)
01108 {
return Socket::setMulticastByFamily(enable, family);}
01109
01110 inline Error join(
const IPV4Multicast &ia)
01111 {
return Socket::join(ia);}
01112
01113
#ifdef CCXX_IPV6
01114 inline Error join(
const IPV6Multicast &ia)
01115 {
return Socket::join(ia);}
01116
#endif
01117
01118 inline Error drop(
const IPV4Multicast &ia)
01119 {
return Socket::drop(ia);}
01120
01121
#ifdef CCXX_IPV6
01122 inline Error drop(
const IPV6Multicast &ia)
01123 {
return Socket::drop(ia);}
01124
#endif
01125
01126
public:
01134 inline ssize_t receive(
void *buf, size_t len)
01135 {
return _IORET64 ::recv(so, (
char *)buf, _IOLEN64 len, 0);};
01136
01143 inline bool isInputReady(
timeout_t timeout = TIMEOUT_INF)
01144 {
return Socket::isPending(Socket::pendingInput, timeout);};
01145 };
01146
01157 class __EXPORT UDPDuplex :
public UDPTransmit,
public UDPReceive
01158 {
01159
public:
01167 UDPDuplex(
const IPV4Address &bind,
tpport_t port);
01168
#ifdef CCXX_IPV6
01169
UDPDuplex(
const IPV6Address &bind,
tpport_t port);
01170
#endif
01171
01181 Error connect(
const IPV4Host &host,
tpport_t port);
01182
#ifdef CCXX_IPV6
01183
Error connect(
const IPV6Host &host,
tpport_t port);
01184
#endif
01185
01192 Error disconnect(
void);
01193 };
01194
01195
01220 class __EXPORT TCPSocket :
protected Socket
01221 {
01222
protected:
01223 int segsize;
01224
void setSegmentSize(
unsigned mss);
01225
01226
public:
01238 virtual bool onAccept(
const IPV4Host &ia,
tpport_t port)
01239 {
return true;}
01240
01244 inline SOCKET getSocket(
void)
01245 {
return so;};
01246
01250 inline int getSegmentSize(
void)
01251 {
return segsize;};
01252
01265 TCPSocket(
const IPV4Address &bind,
tpport_t port,
unsigned backlog = 5,
unsigned mss = 536);
01266
01276 TCPSocket(
const char *service,
unsigned backlog = 5,
unsigned mss = 536);
01277
01286 inline IPV4Host getRequest(
tpport_t *port = NULL)
const
01287
{
return Socket::getIPV4Sender(port);}
01288
01292
void reject(
void);
01293
01297 inline IPV4Host getLocal(
tpport_t *port = NULL)
const
01298
{
return Socket::getIPV4Local(port);}
01299
01305 inline bool isPendingConnection(
timeout_t timeout = TIMEOUT_INF)
01306 {
return Socket::isPending(Socket::pendingInput, timeout);}
01307
01311 virtual ~TCPSocket()
01312 {endSocket();};
01313 };
01314
01315
#ifdef CCXX_IPV6
01316
01340 class __EXPORT TCPV6Socket :
protected Socket
01341 {
01342
private:
01343
int segsize;
01344
void setSegmentSize(
unsigned mss);
01345
01346
public:
01358 virtual bool onAccept(
const IPV6Host &ia,
tpport_t port)
01359 {
return true;}
01360
01364 inline SOCKET getSocket(
void)
01365 {
return so;};
01366
01367 inline int getSegmentSize(
void)
01368 {
return segsize;};
01369
01381 TCPV6Socket(
const IPV6Address &bind,
tpport_t port,
unsigned backlog = 5,
unsigned mss = 536);
01382
01392 TCPV6Socket(
const char *service,
unsigned backlog = 5,
unsigned mss = 536);
01393
01402 inline IPV6Host getRequest(
tpport_t *port = NULL)
const
01403
{
return Socket::getIPV6Sender(port);}
01404
01408
void reject(
void);
01409
01413 inline IPV6Host getLocal(
tpport_t *port = NULL)
const
01414
{
return Socket::getIPV6Local(port);}
01415
01421 inline bool isPendingConnection(
timeout_t timeout = TIMEOUT_INF)
01422 {
return Socket::isPending(Socket::pendingInput, timeout);}
01423
01427 virtual ~TCPV6Socket()
01428 {endSocket();};
01429 };
01430
01431
#endif
01432
01433
01434
01435
01436
01437
01438
01439
01440
#ifdef _MSC_VER
01441
#pragma warning(disable:4275) // disable C4275 warning
01442
#endif
01443
01457 class __EXPORT TCPStream :
protected std::streambuf,
public Socket,
public std::iostream
01458 {
01459
private:
01460
int doallocate();
01461
01462
void segmentBuffering(
unsigned mss);
01463
01464
friend TCPStream& crlf(TCPStream&);
01465
friend TCPStream& lfcr(TCPStream&);
01466
01467
protected:
01468 timeout_t timeout;
01469 size_t bufsize;
01470 Family family;
01471 char *gbuf, *pbuf;
01472
01473
public:
01478 TCPStream(Family family = IPV4,
bool throwflag =
true,
timeout_t to = 0);
01479
01483
void disconnect(
void);
01484
01488
int getSegmentSize(
void);
01489
01490
protected:
01497
void allocate(size_t size);
01498
01503
void endStream(
void);
01504
01511
int underflow();
01512
01521
int uflow();
01522
01530
int overflow(
int ch);
01531
01540
void connect(
const IPV4Host &host,
tpport_t port,
unsigned mss = 536);
01541
#ifdef CCXX_IPV6
01542
void connect(
const IPV6Host &host,
tpport_t port,
unsigned mss = 536);
01543
#endif
01544
01552
void connect(
const char *service,
unsigned mss = 536);
01553
01561 std::iostream *tcp(
void)
01562 {
return ((std::iostream *)
this);};
01563
01564
public:
01575 TCPStream(TCPSocket &server,
bool throwflag =
true,
timeout_t timeout = 0);
01576
#ifdef CCXX_IPV6
01577
TCPStream(TCPV6Socket &server,
bool throwflag =
true,
timeout_t timeout = 0);
01578
#endif
01579
01585
void connect(TCPSocket &server);
01586
#ifdef CCXX_IPV6
01587
void connect(TCPV6Socket &server);
01588
#endif
01589
01600 TCPStream(
const IPV4Host &host,
tpport_t port,
unsigned mss = 536,
bool throwflag =
true,
timeout_t timeout = 0);
01601
#ifdef CCXX_IPV6
01602
TCPStream(
const IPV6Host &host,
tpport_t port,
unsigned mss = 536,
bool throwflag =
true,
timeout_t timeout = 0);
01603
#endif
01604
01614 TCPStream(
const char *service, Family fam = IPV4,
unsigned mss = 536,
bool throwflag =
false,
timeout_t to = 0);
01615
01621 inline void setTimeout(
timeout_t to)
01622 {timeout = to;};
01623
01630 TCPStream(
const TCPStream &source);
01631
01636 virtual ~TCPStream()
01637 {
01638
#ifdef CCXX_EXCEPTIONS
01639
try { endStream(); }
01640
catch( ... ) {
if ( ! std::uncaught_exception())
throw; }
01641
#else
01642
endStream();
01643
#endif
01644
};
01645
01652
int sync(
void);
01653
01654
#ifdef HAVE_SNPRINTF
01655
01661 size_t printf(
const char *format, ...);
01662
#endif
01663
01671
bool isPending(Pending pend,
timeout_t timeout = TIMEOUT_INF);
01672
01680 inline ssize_t peek(
void *buf, size_t len)
01681 {
return _IORET64 ::recv(so, (
char *)buf, _IOLEN64 len, MSG_PEEK);};
01682
01688 inline size_t getBufferSize(
void)
const
01689
{
return bufsize;};
01690 };
01691
01702 class __EXPORT TCPSession :
public TCPStream,
public Thread
01703 {
01704
private:
01705 TCPSession(
const TCPSession &rhs);
01706
protected:
01719
int waitConnection(
timeout_t timeout =
TIMEOUT_INF);
01720
01727
void initial(
void);
01728
01739 void final(
void)
01740 {
delete this;};
01741
public:
01752 TCPSession(
const IPV4Host &host,
01753
tpport_t port, size_t size = 536,
int pri = 0, size_t stack = 0);
01754
#ifdef CCXX_IPV6
01755
TCPSession(
const IPV6Host &host,
01756
tpport_t port, size_t size = 536,
int pri = 0, size_t stack = 0);
01757
#endif
01758
01769 TCPSession(TCPSocket &server,
int pri = 0, size_t stack = 0);
01770
#ifdef CCXX_IPV6
01771
TCPSession(TCPV6Socket &server,
int pri = 0, size_t stack = 0);
01772
#endif
01773
};
01774
01775
#if defined(WIN32)
01776
01786
class init_WSA
01787 {
01788
public:
01789 init_WSA();
01790 ~init_WSA();
01791 };
01792
01793
#endif // WIN32
01794
01795 class __EXPORT
SimpleTCPStream;
01796
01808 class __EXPORT
SimpleTCPStream :
protected Socket
01809 {
01810
private:
01811
01812
inline IPV4Host getSender(
tpport_t *port)
const
01813
{
return IPV4Host(); };
01814
01815
protected:
01820
SimpleTCPStream();
01821
01826
void endStream(
void);
01827
01836
void Connect(
const IPV4Host &host,
tpport_t port, size_t size);
01837
01838
01839
public:
01848
SimpleTCPStream(TCPSocket &server, size_t size = 512);
01849
01858
SimpleTCPStream(
const IPV4Host &host,
tpport_t port, size_t size = 512);
01859
01865
SimpleTCPStream(
const SimpleTCPStream &source);
01866
01871 virtual ~
SimpleTCPStream() { endStream(); };
01872
01884
bool isPending(Pending pend,
timeout_t timeout = TIMEOUT_INF);
01885
01886 void flush() {}
01887
01899 ssize_t read(
char *bytes, size_t length,
timeout_t timeout = 0);
01900
01912 ssize_t write(
const char *bytes, size_t length,
timeout_t timeout = 0);
01913
01927 ssize_t peek(
char *bytes, size_t length,
timeout_t timeout = 0);
01928
01929 };
01930
01931
#ifdef COMMON_STD_EXCEPTION
01932
class __EXPORT SockException :
public IOException
01933 {
01934
private:
01935 Socket::Error _socketError;
01936
01937
public:
01938 SockException(
const String &str, Socket::Error socketError,
long systemError = 0) :
01939 IOException(str, systemError), _socketError(socketError) {};
01940
01941
inline Socket::Error getSocketError()
const
01942
{
return _socketError; }
01943 };
01944
#endif
01945
01946
#ifdef CCXX_NAMESPACES
01947
}
01948
#endif
01949
01950
#endif
01951