6#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
8 #include <sys/socket.h>
10 #include <arpa/inet.h>
14 #include <netinet/in.h>
15 #include <netinet/tcp.h>
17#elif defined(__OS_WINDOWS__)
54 static void close(
int socket );
57 int id(
void )
const {
return soket_; };
60 int port(
void )
const {
return port_; };
63 static bool isValid(
int socket ) {
return socket != -1; };
69 virtual int writeBuffer(
const void *buffer,
long bufferSize,
int flags = 0) = 0;
72 virtual int readBuffer(
void *buffer,
long bufferSize,
int flags = 0) = 0;
75 static int writeBuffer(
int socket,
const void *buffer,
long bufferSize,
int flags );
78 static int readBuffer(
int socket,
void *buffer,
long bufferSize,
int flags );
STK internet socket abstract base class.
Definition Socket.h:39
static void setBlocking(int socket, bool enable)
If enable = false, the socket is set to non-blocking mode. When first created, sockets are by default...
int port(void) const
Return the socket port number.
Definition Socket.h:60
Socket()
Class constructor.
static bool isValid(int socket)
Returns true if the socket descriptor is valid.
Definition Socket.h:63
static int readBuffer(int socket, void *buffer, long bufferSize, int flags)
Read a buffer via the specified socket. Returns the number of bytes read or -1 if an error occurs.
virtual int writeBuffer(const void *buffer, long bufferSize, int flags=0)=0
Write a buffer over the socket connection. Returns the number of bytes written or -1 if an error occu...
int id(void) const
Return the socket descriptor.
Definition Socket.h:57
static void close(int socket)
Close the socket.
virtual ~Socket()
Class destructor.
static int writeBuffer(int socket, const void *buffer, long bufferSize, int flags)
Write a buffer via the specified socket. Returns the number of bytes written or -1 if an error occurs...
virtual int readBuffer(void *buffer, long bufferSize, int flags=0)=0
Read an input buffer, up to length bufferSize. Returns the number of bytes read or -1 if an error occ...
STK base class.
Definition Stk.h:136
The STK namespace.
Definition ADSR.h:6