1 #ifndef TCPSOCKETENGINE_P_H
2 #define TCPSOCKETENGINE_P_H
4 #include "api/internal/io/HostAddress_p.h"
5 #include "api/internal/io/TcpSocket_p.h"
10 struct TcpSocketEngine {
14 TcpSocketEngine(void);
15 TcpSocketEngine(const TcpSocketEngine& other);
16 ~TcpSocketEngine(void);
18 // TcpSocketEngine interface
21 // connection-related methods
23 bool Connect(const HostAddress& address, const uint16_t port);
24 bool Initialize(HostAddress::NetworkProtocol protocol);
25 bool IsValid(void) const;
28 int64_t NumBytesAvailable(void) const;
29 int64_t Read(char* dest, size_t max);
30 int64_t Write(const char* data, size_t length);
32 bool WaitForRead(int msec, bool* timedOut);
33 bool WaitForWrite(int msec, bool* timedOut);
35 // query connection state
36 // HostAddress GetLocalAddress(void) const;
37 // uint16_t GetLocalPort(void) const;
38 HostAddress GetRemoteAddress(void) const;
39 uint16_t GetRemotePort(void) const;
41 int GetSocketDescriptor(void) const;
42 TcpSocket::SocketError GetSocketError(void);
43 TcpSocket::SocketState GetSocketState(void);
45 std::string GetErrorString(void) const;
47 // platform-dependent internal methods
48 // provided in the corresponding TcpSocketEngine_<OS>_p.cpp
50 void nativeClose(void);
51 bool nativeConnect(const HostAddress& address, const uint16_t port);
52 bool nativeCreateSocket(HostAddress::NetworkProtocol protocol);
53 void nativeDisconnect(void);
54 bool nativeFetchConnectionParameters(void);
55 int64_t nativeNumBytesAvailable(void) const;
56 int64_t nativeRead(char* dest, size_t max);
57 int nativeSelect(int msecs, bool isRead) const;
58 int64_t nativeWrite(const char* data, size_t length);
62 int m_socketDescriptor;
64 // HostAddress m_localAddress;
65 HostAddress m_remoteAddress;
66 // uint16_t m_localPort;
67 uint16_t m_remotePort;
69 TcpSocket::SocketError m_socketError;
70 TcpSocket::SocketState m_socketState;
71 std::string m_errorString;
74 } // namespace Internal
75 } // namespace BamTools
77 #endif // TCPSOCKETENGINE_P_H