00001 #ifndef __CONNECTIONINTERFACE_H 00002 #define __CONNECTIONINTERFACE_H 00003 00004 #include "IpAddress.h" 00005 #include "SocketAddress.h" 00006 #include "ObservableInterface.h" 00007 00008 class ConnectionInterface : public ObservableInterface { 00009 public: 00010 OS_SPEC_ENUM EventType { 00011 CONNECTION_CLOSED, 00012 CONNECTION_OPENED 00013 }; 00014 00015 OS_SPEC_ENUM ObjectType { 00016 TCP_CONNECTION = 1, 00017 SSL_CONNECTION = 2, 00018 UNKNOWN_CONNECTION_TYPE = 3 00019 }; 00020 00021 virtual ~ConnectionInterface() {}; 00022 virtual int connect() = 0; 00023 virtual void close() = 0; 00024 virtual int listen() = 0; 00025 virtual ConnectionInterface* accept() = 0; 00026 00027 virtual int read(unsigned char* buffer, int bufferSize, int amountToRead) = 0; 00028 virtual int write(unsigned char* buffer, int amount) = 0; 00029 00030 virtual bool isConnected() = 0; 00031 virtual bool isConnectedTo(IpAddress) = 0; 00032 00033 virtual SocketAddress* getSocketAddress() = 0; 00034 virtual void setSocketAddress(SocketAddress*) = 0; 00035 00036 virtual int getStream() = 0; 00037 virtual void setStream(int) = 0; 00038 00039 virtual ObjectType getConnectionType() = 0; 00040 00041 static ConnectionInterface* createConnectionObject(ObjectType); 00042 }; 00043 00044 #endif