109 int peek(
char *a_output,
unsigned int a_size);
112 int peek(std::string& a_output);
115 int read(
char *a_output,
unsigned int a_size);
118 int read(std::string& a_output);
121 int readLine(
char *a_output,
unsigned int a_size);
124 int readLine(std::string& a_output);
127 int send(
const char *a_data,
int a_length);
130 int send(std::string a_data);
237 static int initialize();
240 static int cleanup();
250 static int m_socketCount;
253 static bool m_initialized;
289 int listen(
unsigned short a_lport,
bool a_block =
true,
bool a_loopback =
false);
292 int broadcast(
unsigned short a_port,
const char *a_data,
int a_length);
295 int broadcast(
unsigned short a_port,
const std::string& a_data);
298 int setPeer(
const char *a_address,
unsigned short a_port,
bool a_block =
true);
301 int connect(
const char *a_address,
unsigned short a_port,
unsigned short a_localport,
bool a_block =
true);
346 int connect(
const char *a_address,
unsigned short a_port,
bool a_block =
true,
double a_timeout = -1.0);
349 int listen(
unsigned short a_port,
bool a_block =
true,
bool a_loopback =
false);
This class implements all methods shared by TCP and UDP sockets.
Definition CSocket.h:75
static std::string getLocalIP()
This method retrieves the local IP address.
Definition CSocket.cpp:125
int setSendSize(int a_size)
This method sets the socket outgoing buffer size.
Definition CSocket.cpp:665
int getSendSize()
This method retrieves the socket outgoing buffer size.
Definition CSocket.cpp:636
int readLine(char *a_output, unsigned int a_size)
This method reads an entire line of data (delimited by the '\n' character).
Definition CSocket.cpp:445
int m_socket
Unique socket identifier.
Definition CSocket.h:209
int send(const char *a_data, int a_length)
This method sends data through the socket.
Definition CSocket.cpp:546
virtual int setAttributes(unsigned char a_attributes)=0
This method sets the socket attributes.
int close()
This method closes the socket.
Definition CSocket.cpp:217
static const unsigned char REUSEADDR
This constant defines the attribute bit to hold the socket REUSEADDR attribute.
Definition CSocket.h:170
int peek(char *a_output, unsigned int a_size)
This method reads a copy of incoming data (without removing the data).
Definition CSocket.cpp:248
static const unsigned char BLOCKING
This constant defines the attribute bit to hold the socket BLOCKING attribute.
Definition CSocket.h:167
unsigned long m_remoteIP
Socket remote IP address.
Definition CSocket.h:218
int getRecvSize()
This method retrieves the socket incoming buffer size.
Definition CSocket.cpp:689
double getTimeout()
This method retrieves the socket timeout in (s).
Definition CSocket.cpp:606
std::string getRemoteIP()
This method retrieves the remote IP address that the socket is connected to.
Definition CSocket.cpp:185
unsigned long m_localIP
Socket local IP address.
Definition CSocket.h:224
unsigned int m_localPort
Socket local port number.
Definition CSocket.h:227
int getRemotePort()
This method returns the remote port number that the socket is connected to.
Definition CSocket.cpp:204
static const unsigned char NODELAY
This constant defines the attribute bit to hold the socket NODELAY attribute.
Definition CSocket.h:173
int setRecvSize(int a_size)
This method sets the socket incoming buffer size.
Definition CSocket.cpp:718
static const int SHORTLINE
This return constant is used to signify that a buffer is too small to hold a line.
Definition CSocket.h:182
unsigned char m_attributes
Socket attributes.
Definition CSocket.h:212
static const unsigned char DEFAULT_ATTR
This constant defines the default attributes for new sockets.
Definition CSocket.h:176
static const int TIMEOUT
This return constant is used to signify that a read operation on a socket has timed out.
Definition CSocket.h:185
unsigned char getBaseAttributes()
This method retrieves the socket attributes shared between TCP and UDP.
Definition CSocket.cpp:747
unsigned int m_remotePort
Socket remote port number.
Definition CSocket.h:221
int getLocalPort()
This method returns the local port number that the socket is connected to.
Definition CSocket.cpp:170
virtual ~cSocket()
Definition CSocket.cpp:107
char m_buffer[BUFFERSIZE]
Socket read buffer.
Definition CSocket.h:215
int setBaseAttributes(unsigned char a_attributes)
This method sets the socket attributes shared between TCP and UDP.
Definition CSocket.cpp:767
static const unsigned int BUFFERSIZE
This constant defines the default outgoing and incoming socket buffer sizes.
Definition CSocket.h:164
int read(char *a_output, unsigned int a_size)
This method reads a incoming data.
Definition CSocket.cpp:359
virtual unsigned char getAttributes()=0
This method retrieves the socket attributes.
cSocket()
Definition CSocket.cpp:67
int setTimeout(double a_timeout)
This method sets the socket timeout in (s).
Definition CSocket.cpp:622
static const int WOULDBLOCK
This return constant is used to signify that a non-blocking socket would block.
Definition CSocket.h:179
This class implements all methods specific to TCP sockets.
Definition CSocket.h:322
unsigned char getAttributes()
This method retrieves the socket attributes.
Definition CSocket.cpp:1575
cSocketTCP * accept(bool a_block=true, double a_timeout=-1.0)
This method accepts connections from incoming client connection requests.
Definition CSocket.cpp:1493
cSocketTCP()
Constructor of cSocketTCP.
Definition CSocket.cpp:1240
int listen(unsigned short a_port, bool a_block=true, bool a_loopback=false)
This method listens for incoming client connections.
Definition CSocket.cpp:1407
int connect(const char *a_address, unsigned short a_port, bool a_block=true, double a_timeout=-1.0)
This method connects to a remote server.
Definition CSocket.cpp:1288
int setAttributes(unsigned char a_attributes)
This method sets the socket attributes.
Definition CSocket.cpp:1598
virtual ~cSocketTCP()
Destructor of cSocketTCP.
Definition CSocket.cpp:1265
This class implements all methods specific to UDP sockets.
Definition CSocket.h:268
int listen(unsigned short a_lport, bool a_block=true, bool a_loopback=false)
This method listens for incoming packets on a given port.
Definition CSocket.cpp:905
int connect(const char *a_address, unsigned short a_port, unsigned short a_localport, bool a_block=true)
This method connects to a given remote socket.
Definition CSocket.cpp:1111
virtual ~cSocketUDP()
Destructor of cSocketUDP.
Definition CSocket.cpp:882
int broadcast(unsigned short a_port, const char *a_data, int a_length)
This method broadcast a packet to a given port.
Definition CSocket.cpp:983
unsigned char getAttributes()
This method retrieves the socket attributes.
Definition CSocket.cpp:1209
int setPeer(const char *a_address, unsigned short a_port, bool a_block=true)
This method assigns a peer (remote) socket to the current socket.
Definition CSocket.cpp:1055
int setAttributes(unsigned char a_attributes)
This method sets the socket attributes.
Definition CSocket.cpp:1229
cSocketUDP()
Constructor of cSocketUDP.
Definition CSocket.cpp:871
Definition CAudioBuffer.cpp:57