5 link with ws2_32.lib in Windows
\r
13 #include <winsock2.h>
\r
14 #include <windows.h>
\r
16 #include <sys/types.h>
\r
17 #include <sys/socket.h>
\r
18 #include <netinet/in.h>
\r
19 #include <arpa/inet.h>
\r
27 class FCPMessage:public std::map<std::string, std::string >
\r
31 FCPMessage(const std::string &name) {m_name=name;}
\r
33 const std::string GetName() const { return m_name; }
\r
34 void SetName(const std::string &name) { m_name=name; }
\r
36 void Reset() { m_name=""; clear(); }
\r
48 const bool Connect(const char *host, const int port);
\r
49 const bool Disconnect();
\r
51 const bool Connected() const { return m_serversocket!=-1 ? true : false ; }
\r
53 const bool Update(const long waittime);
\r
55 const int SendMessage(const char *messagename, const int fieldcount, ...);
\r
56 const int SendMessage(FCPMessage &message);
\r
57 const int SendRaw(const char *data, const int datalen);
\r
58 const std::vector<char>::size_type SendBufferSize() const { return m_sendbuffer.size(); }
\r
60 FCPMessage ReceiveMessage();
\r
61 const long ReceiveRaw(char *data, long &datalen); // data must be preallocated, with datalen being max length of data. Returns length of data received
\r
62 const std::vector<char>::size_type ReceiveBufferSize() const { return m_receivebuffer.size(); }
\r
66 void SocketReceive();
\r
69 void SendBufferedText(const char *text); // puts text on send buffer
\r
70 void SendBufferedRaw(const char *data, const long len); // puts raw data on send buffer
\r
72 int FindOnReceiveBuffer(const char *text); // finds text string on receive buffer and returns index to first char position, -1 if not found
\r
76 static bool m_wsastartup;
\r
81 char *m_tempbuffer; // temp buffer used for recv
\r
83 std::vector<char> m_sendbuffer;
\r
84 std::vector<char> m_receivebuffer;
\r
88 struct timeval m_timeval;
\r