51#include <netinet/in.h>
52#include <netinet/tcp.h>
53#include <sys/socket.h>
56#define ZSOCKLEN socklen_t
79 bool Bind(
unsigned short port);
129 operator const ZSOCKET&()
const {
return m_socket; }
Definition AcceleratorBuffer.h:204
Class representing a network socket.
Definition Socket.h:65
int m_protocol
Protocol of the socket.
Definition Socket.h:156
bool Connect(const std::string &host, uint16_t port)
Establishes a TCP connection to a remote host.
Definition Socket.cpp:132
bool SendPascalString(const std::string &str)
Sends a string to a socket.
Definition Socket.cpp:570
bool DisableDelayedACK()
Disable delayed-ACK so that we send ACKs immediately upon packet receipt.
Definition Socket.cpp:628
void FlushRxBuffer(void)
Flush RX buffer.
Definition Socket.cpp:356
int m_af
Address family of this socket (typically AF_INET or AF_INET6)
Definition Socket.h:150
virtual ~Socket(void)
Closes a socket.
Definition Socket.cpp:97
size_t GetRxBytesAvailable() const
Return the number of unread bytes in the RX buffer.
Definition Socket.cpp:703
ZSOCKET Detach()
Detaches the socket from this object.
Definition Socket.cpp:551
bool RecvLooped(unsigned char *buf, int len)
Recives data from a UDP socket.
Definition Socket.cpp:301
bool Bind(unsigned short port)
Binds the socket to an address.
Definition Socket.cpp:399
Socket Accept()
Accepts a connection on the socket.
Definition Socket.cpp:491
bool Listen()
Puts the socket in listening mode.
Definition Socket.cpp:448
bool RecvPascalString(std::string &str)
Reads a Pascal-style string from a socket.
Definition Socket.cpp:592
bool SetReuseaddr(bool on=true)
Set SO_REUSEADDR on our socket, allowing binding to it again without waiting for timeout if our task ...
Definition Socket.cpp:647
int m_type
Type of the socket.
Definition Socket.h:153
ZSOCKET m_socket
The socket handle.
Definition Socket.h:165
bool DisableNagle()
Disable the Nagle algorithm on the socket so that messages get sent right away.
Definition Socket.cpp:614
bool SendLooped(const unsigned char *buf, int count)
Sends data over the socket.
Definition Socket.cpp:214