barrier/CUnixTCPSocket.h
crs fe79ac593c more fixes to reduce latency. nagle agorithm doesn't seem to
stay off on a socket on linux because a connection clearly
doesn't send data as often as possible.  will have to implement
a UDP socket to reduce overhead and avoid these delays.  wanted
to do that anyway.
2001-05-13 12:43:16 +00:00

51 lines
1.1 KiB
C++

#ifndef CUNIXTCPSOCKET_H
#define CUNIXTCPSOCKET_H
#include "CSocket.h"
#include "CSocketFactory.h"
class CUnixTCPSocket : public CSocket {
public:
CUnixTCPSocket();
virtual ~CUnixTCPSocket();
// ISocket overrides
virtual void connect(const CString& hostname, UInt16 port);
virtual void listen(const CString& hostname, UInt16 port);
virtual ISocket* accept();
virtual SInt32 read(void* buffer, SInt32 numBytes);
virtual void write(const void* buffer, SInt32 numBytes);
protected:
// CSocket overrides
virtual void onJobChanged();
private:
CUnixTCPSocket(int);
// disable Nagle algorithm
void setNoDelay();
// callbacks for read/write events
void readCB();
void writeCB();
private:
enum EState { kNone, kConnecting, kConnected, kListening };
int m_fd;
EState m_state;
bool m_addedJobs;
};
class CUnixTCPSocketFactory : public CSocketFactory {
public:
CUnixTCPSocketFactory() { }
virtual ~CUnixTCPSocketFactory() { }
// CSocketFactory overrides
virtual ISocket* create() const
{ return new CUnixTCPSocket; }
};
#endif