00001 00014 // TcpSocket.h -- interface for the TcpSocket class 00015 00016 #ifndef TCPSOCKET_H_ 00017 #define TCPSOCKET_H_ 00018 00019 #ifdef _MSC_VER 00020 #pragma once 00021 #endif // MSVC 00022 00023 #include "ConnectableSocket.h" 00024 00026 // TcpSocket 00027 00028 // TcpSocket builds upon the ConnectalbeSocket class to provide TCP services. 00029 // Application level protocols such as FTP,SMTP,HTTP can be built on top of the TcpSocket 00030 00031 class TcpSocket : public ConnectableSocket 00032 { 00033 public: 00034 // Binding state enumeration 00035 enum TcpBinding 00036 { 00037 bound, 00038 unbound 00039 }; 00040 00041 // Default constructor 00042 TcpSocket(TcpBinding binding = bound); 00043 00044 // Construct from the given SocketAddress 00045 TcpSocket(const SocketAddress& address); 00046 00047 // Construct from the operating system handle 00048 TcpSocket(SOCKET socketHandle); 00049 00050 // Close and reopen the TcpSocket (all active connections will be lost) 00051 void reset(); 00052 00053 // Whether keep-alives are being sent 00054 bool keepAlive() const; 00055 00056 // Set whether keepalives are being sent over the TcpSocket 00057 void setKeepAlives(bool flag); 00058 00059 protected: 00060 // Hide the copy constructor and assignment operator 00061 TcpSocket(const TcpSocket&); 00062 void operator=(const TcpSocket&); 00063 }; 00064 00065 #endif // TCPSOCKET_H_