00001 //************************************************************************** 00002 #ifndef _TCPSOCKET_H 00003 #define _TCPSOCKET_H 00004 //************************************************************************** 00005 #include <netinet/in.h> 00006 //************************************************************************** 00007 class TCPSocket { 00008 00009 public: 00011 TCPSocket(); 00013 ~TCPSocket(); 00014 00016 bool Bind(int port); 00017 00019 bool Listen(); 00020 00022 bool Accept(); 00023 00025 bool Connect(char *server, int port); 00026 00028 int SendBytes(int size, const void *data); 00029 00031 int RecvBytes(int size, void *data); 00032 00034 bool Close(); 00035 00037 bool InboundClose(); 00038 00040 char *SocketName(); 00042 int SocketPort(); 00043 00045 char *PeerName(); 00047 int PeerPort(); 00048 00050 double BytesSent(); 00051 00053 double BytesRecd(); 00054 00056 int SendTime(); 00057 00059 int RecvTime(); 00060 00062 double SendRate() { return 8.0*BytesSent()/(1000.0*SendTime()); } 00063 00065 double RecvRate() { return 8.0*BytesRecd()/(1000.0*RecvTime()); } 00066 00068 TCPSocket &operator= (const TCPSocket &); 00069 00070 private: 00071 int sockfd, recvfd; 00072 sockaddr_in INetAddress, RemoteAddress; 00073 00075 bool Create(); 00076 }; 00077 //************************************************************************** 00078 #endif 00079 //**************************************************************************
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001