A simple class to do line-based TCP communication. To be used with the NetServicesMin library-.
tcplinestream.h
- Committer:
- hlipka
- Date:
- 2011-01-29
- Revision:
- 0:f2727a16072f
- Child:
- 1:28416a5a4ec5
File content as of revision 0:f2727a16072f:
#ifndef __TCPLINESTREAM__H__ #define __TCPLINESTREAM__H__ #include "TCPSocket.h" #include "string" #define BUFSIZE 1024 using namespace std; class TCPLineStream { public: TCPLineStream(const char *host, int port, const char* _term="\r\n"); ~TCPLineStream(){close();}; bool open(); void close(); string readLine(int strLen=64); void sendLine(string line); private: void init(); void onTCPSocketEvent(TCPSocketEvent e); const char *_server; int _port; bool _connecting; bool _connected; bool _closed; TCPSocket *_socket; char _readbuf[BUFSIZE]; int _readpos; int _readlen; const char* _term; }; #endif