关于用异步SOCKET传输文件,哪位高手能帮小弟我解答

关于用异步SOCKET传输文件,谁能帮我解答
用异步,SOCKET,从服务器端向客户端传送文件
谁能给个方法   该怎么做?

------解决方案--------------------
int CDataSocket::Receive()
{
int nRead = 0;

if (m_nStatus == XFERMODE_RECEIVE)
{
if (m_File.m_hFile == NULL)
return 0;

byte data[PACKET_SIZE];
nRead = CAsyncSocket::Receive(data, PACKET_SIZE);

switch(nRead)
{
case 0:
{
m_File.Close();
m_File.m_hFile = NULL;
Close();
// tell the client the transfer is complete.
m_pConnectSocket-> SendResponse( "226 Transfer complete 4 ");
// destroy this socket
AfxGetThread()-> PostThreadMessage(WM_THREADMSG, 0, 0);
// upload succesfull
((CConnectThread *)AfxGetThread())-> UpdateStatistic(FTPSTAT_UPLOADSUCCEEDED);
ProcessFiles();
break;
}
case SOCKET_ERROR:
{
if (GetLastError() != WSAEWOULDBLOCK)
{
m_File.Close();
m_File.m_hFile = NULL;
Close();
m_pConnectSocket-> SendResponse( "426 Connection closed; transfer aborted. SOCKET_ERROR ");
// destroy this socket
AfxGetThread()-> PostThreadMessage(WM_THREADMSG, 0, 0);
// upload failed
((CConnectThread *)AfxGetThread())-> UpdateStatistic(FTPSTAT_UPLOADFAILED);

}
break;
}
default:
{
((CConnectThread *)AfxGetThread())-> IncReceivedBytes(nRead);

TRY
{
m_File.Write(data, nRead);
}
CATCH_ALL(e)
{
m_File.Close();
m_File.m_hFile = NULL;
Close();
m_pConnectSocket-> SendResponse( "450 can 't access file. ");
// destroy this socket
AfxGetThread()-> PostThreadMessage(WM_THREADMSG, 0, 0);
// upload failed
((CConnectThread *)AfxGetThread())-> UpdateStatistic(FTPSTAT_UPLOADFAILED);
ProcessFiles();
return 0;
}
END_CATCH_ALL;

break;

}
}
}
return nRead;
}



void CDataSocket::OnReceive(int nErrorCode)
{
CAsyncSocket::OnReceive(nErrorCode);

Receive();
}

void CDataSocket::OnAccept(int nErrorCode)
{
CAsyncSocket socky;
Accept(socky);

SOCKET socket = socky.Detach();
Close();

Attach(socket);

m_bConnected = TRUE;
m_pConnectSocket-> SendResponse( "150 Connection accepted ");

CAsyncSocket::OnAccept(nErrorCode);

m_bPassiveMode = TRUE;
//m_bPassiveMode = FALS
}


void CDataSocket::OnConnect(int nErrorCode)
{
if (nErrorCode)
{
m_nStatus = XFERMODE_ERROR;
m_pConnectSocket-> SendResponse( "425 Can 't open data connection. 4 ");
// destroy this socket
AfxGetThread()-> PostThreadMessage(WM_THREADMSG, 0, 0);
}
else
{
switch (m_nTransferType)
{
case 0: // List Directory
m_nStatus = XFERMODE_LIST;