41 mSockState( STATE_DISCONNECTED ),
50 mSockState( STATE_CONNECTED ),
61 _log(THREAD__WARNING,
"Destroying TCPConnection for thread 0x%X", pthread_self());
106 sockaddr_in server_sin;
107 server_sin.sin_family = AF_INET;
108 server_sin.sin_addr.s_addr = rIP;
109 server_sin.sin_port = htons( rPort );
121 int bufsize = 64 * 1024;
122 mSock->
setopt( SOL_SOCKET, SO_RCVBUF, (
char*) &bufsize,
sizeof( bufsize ) );
221 _log(TCP_CLIENT__TRACE,
"Process() - Connecting Failed at %s: %s",
GetAddress().c_str(), errbuf );
224 _log(TCP_CLIENT__INFO,
"Process() - TCP connectection from %s",
GetAddress().c_str() );
229 _log(TCP_CLIENT__TRACE,
"Process() - Connected RecvData() Failed at %s: %s",
GetAddress().c_str(), errbuf );
233 _log(TCP_CLIENT__TRACE,
"Process() - Connected SendData() Failed at",
"%s: %s",
GetAddress().c_str(), errbuf );
240 _log(TCP_CLIENT__TRACE,
"Process() - Disconnecting SendData() Failed at",
"%s: %s",
GetAddress().c_str(), errbuf );
276 if (errno == EWOULDBLOCK) {
286 if ((
size_t)status > buf->
size()) {
292 }
else if ((
size_t)status < buf->size()) {
327 if (errno == EWOULDBLOCK)
332 }
else if (status == 0) {
343 _log(TCP_CLIENT__ERROR,
"TCPConnection::RecvData(): Error: recv() returned unknown status");
381 assert( tcpc !=
nullptr );
384 sThread.RemoveThread(pthread_self());
Simple wrapper for sockets.
virtual ~TCPConnection()
Cleans connection up.
const uint32 TCPCONN_LOOP_GRANULARITY
#define _log(type, fmt,...)
A lock for a Lockable object.
void WaitLoop()
Blocks calling thread until working thread terminates.
virtual bool RecvData(char *errbuf=0)
Receives data and puts them into receive queue.
virtual bool SendData(char *errbuf=0)
Sends data in send queue.
void Lock()
Locks the mutex.
virtual void ClearBuffers()
Clears send and receive buffers.
bool Send(Buffer **data)
Enqueues data to be sent.
const uint32 TCPCONN_RECVBUF_SIZE
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
TCPConnection()
Creates new connection in STATE_DISCONNECTED.
static const uint32 TCPCONN_ERRBUF_SIZE
Generic class for buffers.
void StartLoop()
Starts working thread.
unsigned int recv(void *buf, unsigned int len, int flags)
void Resize(size_type requiredCount, const uint8 &fill=0)
Resizes buffer.
int setopt(int level, int optname, const void *optval, unsigned int optlen)
void Unlock()
Unlocks the mutex.
virtual bool Process()
Does all stuff that needs to be periodically done to keep connection alive.
Generic class for TCP connections.
static void * TCPConnectionLoop(void *arg)
Loop for worker threads.
std::deque< Buffer * > mSendQueue
void AsyncConnect(uint32 rIP, uint16 rPort)
Schedules asynchronous connect to specified address.
unsigned int send(const void *buf, unsigned int len, int flags)
bool Connect(uint32 rIP, uint16 rPort, char *errbuf=0)
Connects to specified address.
void Disconnect()
Schedules disconnect of current connection.
int fcntl(int cmd, long arg)
void AssignSeq(Iter first, Iter last)
Assigns a sequence of elements to buffer.
void DoDisconnect()
Disconnects socket.
int connect(const sockaddr *name, unsigned int namelen)
entityID heal the character with the entityID note giving you detailed ship status information gives a list of all dynamic entities and players and their destinyState in this bubble shows some current destiny variables save all kick all and halt server immediate command list all items in current location s gives list of cargo contents and volumes in all holds list current session values show current ship DNA show current objects in their destiny state
void TCPConnectionLoop()
Loop for worker threads.
virtual bool ProcessReceivedData(char *errbuf=0)=0
Processes received data.