00001
00002
00003
00004
00005
00006 #ifndef __J2K__NET__TCPSOCKET_HPP__
00007 #define __J2K__NET__TCPSOCKET_HPP__
00008
00009
00010
00011 #include <j2k/Net/include.hpp>
00012 #include <j2k/Net/Socket.hpp>
00013 #include <j2k/Net/InetAddress.hpp>
00014
00015 class TcpSocket : public Socket {
00016
00017 public:
00018 TcpSocket(int port = 0) throw(int);
00019 TcpSocket(Socket &original) throw(int);
00020
00021 TcpSocket(InetAddress& address, int port = 0) throw(int);
00022 TcpSocket(InetAddress& remoteAddr, int remotePort, InetAddress& localAddress, int localPort) throw(int);
00023 #ifdef USE_JSTRING
00024 TcpSocket(JString &host, int port) throw(int);
00025 TcpSocket(JString &remoteHost, int remotePort, InetAddress& localHost, int localPort) throw(int);
00026
00027 JString getLocalHost() const;
00028 JString getHost() const;
00029 #else
00030 TcpSocket(char *host, int port) throw(int);
00031 TcpSocket(char *remoteHost, int remotePort, InetAddress& localHost, int localPort) throw(int);
00032
00033 const char* getLocalHost() const;
00034 const char* getHost() const;
00035 #endif
00036 InetAddress getLocalAddress() const;
00037 InetAddress getInetAddress() const;
00038 int getLocalPort() const;
00039 int getPort() const;
00040
00041
00042
00043
00044 int setTcpNoDelay(BOOL on);
00045 int setSoLinger(BOOL on, int linger);
00046 int setSoTimeout(int timeout);
00047 int setSendBufferSize(int size);
00048 int setRecieveBufferSize(int size);
00049 int setKeepAlive(BOOL on);
00050
00051
00052 BOOL getTcpNoDelay();
00053 int getSoLinger();
00054 int getSoTimeout();
00055 int getSendBufferSize();
00056 int getRecieveBufferSize();
00057 BOOL getKeepAlive();
00058
00059
00060
00061
00062
00063
00064
00065 int read(char * buffer, size_t len, int flags = 0);
00066 int send(char * buffer, size_t len, int flags = 0);
00067
00068
00069 protected:
00070 InetAddress *remoteAddress;
00071 int remotePort;
00072 int localPort;
00073
00074 };
00075
00076 #endif //__J2K__NET__TCPSOCKET_HPP__