www.pudn.com > Ftpwork > FtpSocket.h


/***************************************************************************
                          FtpSocket.h  -  description
                             -------------------
    begin                : Tue Oct 22 2002
    copyright            : (C) 2002 by 
    email                : 
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef FTPSOCKET_H
#define FTPSOCKET_H

#include 
#include 
#include 
#include "Basic.h"





/**
  *@author 
  */

//##ModelId=3DB4E14C0211
class FtpSocket {

public: 

    //##ModelId=3DB5036E01CF
	FtpSocket();
    //##ModelId=3DB5036E01D0
    //##Documentation
    //## Create a FtpSocket object with a certain socket id.
	FtpSocket(int newsocket);
    //##ModelId=3DB5036E01D9
	~FtpSocket();	
    //##ModelId=3DB5036E01E3
	BOOL  Bind(struct sockaddr* localaddr);

    //##ModelId=3DB5036E01ED
	void  Listen(int max_pending);
	
	
	BOOL Send(void* buf, size_t len, int isBlock, int flag=0);
	
	
  int  Recv(char* buf, size_t len, int isBlock, int flag=0);	
    //##ModelId=3DB5036E0201
    //##Documentation
    //## Send a data stroed in the buffer with the option of bloaking or not.
    //## If block ,this mathed will not return until the peer give an answer.
	BOOL 	SendData(void* buf, size_t len, int isBlock, int flag=0);	
    //##ModelId=3DB5036E0229
    //##Documentation
    //## If there is a connect to this socket,  this function return a new
    //## object of FtpSocket .
	FtpSocket Accept();	
    //##ModelId=3DB5036E0233
	void 	Close();	
    //##ModelId=3DB5036E0234
    //##Documentation
    //## Connect a specified IP address.
	BOOL  Connect(struct sockaddr* remoteaddr);	
    //##ModelId=3DB5036E0247
    //##Documentation
    //## To receive data with option of block or not. if block, the FtpSocket
    //## will send an ACK to the sender. This function will not return until
    //## thieir is someting received.
	int 	RecvData(char* buf, size_t len, int isBlock, int flag=0);
    //##ModelId=3DB50C980042
    //##Documentation
    //## Open the FtpSocket to be used i n communicating.
    BOOL Open();


	
	
private:
    //##ModelId=3DB5036E017F
    //##Documentation
    //## 接收应答字符串的缓冲区
	char   	ackbuf[1024];
    //##ModelId=3DB5036E01A7
    //##Documentation
    //## 本类使用的socket()返回的socket标识。
	int 		socketid;
    //##ModelId=3DB5036E01B1
    //##Documentation
    //## 用来发送的应答信号。
	char  	ack[2];
    //##ModelId=3DB5036E01BB
    //##Documentation
    //## the address of remote computer who has connected this Socket Object
	struct  sockaddr  remoteaddr;
	
};

#endif