www.pudn.com > rDUNclientBeta1.zip > server.h


//rDUN Client - Server interface class 
//Copyright (C) Robert Merrison 2002  
 
//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License  
//as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied  
//warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 
//You should have received a copy of the GNU General Public License along with this program; if not, write to the  
//Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
#ifndef _SERVER_H_ 
#define _SERVER_H_ 
 
#include  
#include  
 
#define PROTOCOL_VERSION	2 
 
#define SD_RECEIVE      0x00 
#define SD_SEND         0x01 
#define SD_BOTH         0x02 
 
#define WM_ONSOCKET WM_USER+2 
#define WM_RCSTATECHANGE WM_USER+3 
 
#define RCSTATE_UNKNOWN				0 
#define RCSTATE_CONNECTED			1 
#define RCSTATE_CONNECTING			2 
#define RCSTATE_DISCONNECTED		3 
#define RCSTATE_DISCONNECTING		4 
#define RCSTATE_USERDISCONNECTED	5 
#define RCSTATE_USERDISCONNECTING	6 
 
#define STATE_DISCONNECTED		0 
#define STATE_IDLE				1 
#define STATE_LOGIN				2 
#define	STATE_PROTOCONFIRM		3 
 
class server_c{ 
public: 
	server_c(); 
	~server_c(); 
 
	bool	connectTo( char* address, unsigned short port, HWND windowHandle, char* password ); 
	void	disconnectFrom(); 
	 
	void	rCConnect(); 
	void	rCDisconnect(); 
 
	void	onRead(); 
	void	onWrite(); 
	void	onClose(); 
	void	onConnect(); 
		 
private: 
	void	processRecvBuffer(); 
	void	sendData( char* data ); 
	 
	SOCKET connectSocket; 
	char sendBuffer[256]; 
	char recvBuffer[256]; 
	char password[128]; 
 
	HWND appWindowHandle; 
 
	int rConnectionState; 
	int currentState; 
}; 
#endif