Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

How Proxy Server serves FTP clients?

, 10 Feb 2005
This article describes how Proxy Server deals with PORT and PASV FTP commands
proxyftp_demo.zip
LiteProxyServer.exe
proxyftp_src.zip
IPHlpApi.Lib
RES
LiteProxyServerDoc.ico
Mem1.ICO
Mem2.ICO
Mem3.ICO
Mem4.ICO
Mem5.ICO
Mem6.ICO
Mem7.ICO
Mem8.ICO
Mem9.ICO
Mem10.ICO
ChatRoom.ico
LiteProxyServer.ico
Toolbar.bmp
BITMAP1.BMP
BMP00001.BMP
BMP00002.BMP
LiteProxyServer.dsp
LiteProxyServer.dsw
#if (!defined(__NEURO__SOCKET__CLIENT__))
#define __NEURO__SOCKET__CLIENT__

#include "SocketEx.h"

class CSocketException : public CException{
public:
	CString m_strError;

	CSocketException(LPCTSTR lpszError,LPCTSTR lpszDetails)
	{
		m_strError = lpszError;
		m_strError += "\n";
		if(lpszDetails)
		{
			m_strError += "System Error Detail:";
			m_strError += lpszDetails;
		}
	}

	BOOL GetErrorMessage(LPTSTR lpszError,UINT nMaxError, PUINT pnHelpContext = NULL)
	{
		strncpy(lpszError,(LPCTSTR)m_strError,nMaxError);
		return true;
	}
};











/************************************************************************
		 
		 Name   : CSocketClient
		 Type   : Class
------------------------------------------------------------------------
		 Author : Akash Kava
		 Purpose: Client socket derived from CSocketEx and introduces 
		          Exception to rise when Data is unavailable or timedout

				  CSocketEx does not throw any exception at all.
************************************************************************/

class CSocketClient : protected CSocketEx{
public:

	CSocketClient()
		: CSocketEx()
	{
		Create(0,NULL);
		
	}

	void Close()
	{
		CSocketEx::Close();
	}

	void ConnectTo(LPCTSTR lpszHost , int nPort)
	{
		if(!Connect(lpszHost,nPort))
			throw new CSocketException(CString("Could not connect to server ") + CString(lpszHost),GetLastError());
	}

	unsigned __int8  ReadInt8()
	{
		unsigned __int8 data;
		if(Receive(&data,1) != 1)
			throw new CSocketException("Error readint socket data",GetLastError());
		return data;
	}

	unsigned __int16 ReadInt16()
	{
		unsigned __int16 data;
		if(Receive(&data,2) != 2)
			throw new CSocketException("Error reading socket data",GetLastError());
		data = ntohs(data);
		return data;
	}

	unsigned __int32 ReadInt32()
	{
		unsigned __int32 data;
		if(Receive(&data,4)!=4)
			throw new CSocketException("Error reading socket data",GetLastError());
		data = ntohl(data);
		return data;
	}

	void WriteInt8(unsigned __int8 data)
	{
		if(Send(&data,1)!=1)
			throw new CSocketException("Error writing socket data",GetLastError());
	}

	void WriteInt16(unsigned __int16 data)
	{
		data = htons(data);
		if(Send(&data,2)!=2)
			throw new CSocketException("Error writing socket data",GetLastError());
	}

	void WriteInt32(unsigned __int32 data)
	{
		data = htonl(data);
		if(Send(&data,4)!=4)
			throw new CSocketException("Error writing socket data",GetLastError());
	}

	void WriteBytes (void * Buffer, int Length)
	{
		if(Send(Buffer,Length)!=Length)
			throw new CSocketException("Error writing socket data",GetLastError());
	}

	void ReadBytes (void * Buffer , int Length)
	{
		if(Receive(Buffer,Length)!=Length)
			throw new CSocketException("Error reading socket data",GetLastError());
	}

};
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 10 Feb 2005
Article Copyright 2005 by Hatem Mostafa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid