summaryrefslogtreecommitdiff
path: root/Bus/Ivy/BufferedSocket.h
blob: e72138f147ef64bd714e223b4c57bb874c5e425b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// BufferedSocket.h: interface for the CBufferedSocket class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BUFFEREDSOCKET_H__ECAC808B_3B4D_11D3_8A1E_00A0245B298A__INCLUDED_)
#define AFX_BUFFEREDSOCKET_H__ECAC808B_3B4D_11D3_8A1E_00A0245B298A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "ThreadedSocket.h"

class CBufferedSocket : public CThreadedSocket  
{
//	DECLARE_DYNAMIC(CBufferedSocket)
public:
	CBufferedSocket();
	virtual ~CBufferedSocket();
	void OnReceive( int nErrorCode );
	void OnSend( int nErrorCode );
	void OnConnect(int nErrorCode);
	void OnWakeup();
	virtual void OnReceive( char *line );
	virtual void Accept(CBufferedSocket& rConnectedSocket,
		SOCKADDR* lpSockAddr = NULL, int* lpSockAddrLen = NULL);
	void SetSeparator( char sep );
	void Send ( const char * data );
protected:
	bool connected;	/* wait to be connected before sending any Data */
	char separator;
	/* buffer de reception de l'application */
#define MAX_BUFFER 2048
	// MAX_BUFFER +1 pour ajouter \0 a la fin
	char buf[MAX_BUFFER+1];
	char *ptr;
	// Buffer Emission
	CRITICAL_SECTION  m_CritSection;
	std::list<String> buf_out;
};

#endif // !defined(AFX_BUFFEREDSOCKET_H__ECAC808B_3B4D_11D3_8A1E_00A0245B298A__INCLUDED_)