我的问题不知道怎么弄的,糊里糊涂就搞定了不得 :)
有人提供CAsyncSocket的源码就给分(要有OnSend()或OnRecv()的啦)
谢谢大家啦!!!!

解决方案 »

  1.   

    从CAsyncSocket派生一个类CSockRecv,那么:
    在void CSockRecv::OnReceive(int nErrorCode)中接受数据。
    在OnSend中发送数据!
      

  2.   

    class CClientSck : public CAsyncSocket
    {
    // Attributes
    public:// Operations
    public:
    CClientSck();
    virtual ~CClientSck();// Overrides
    public:
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CClientSck)
    public:
    virtual void OnReceive(int nErrorCode);
    virtual void OnConnect(int nErrorCode);
    //}}AFX_VIRTUAL // Generated message map functions
    //{{AFX_MSG(CClientSck)
    // NOTE - the ClassWizard will add and remove member functions here.
    //}}AFX_MSG// Implementation
    protected:
    };CClientSck::CClientSck()
    {
    }CClientSck::~CClientSck()
    {
    }
    // Do not edit the following lines, which are needed by ClassWizard.
    #if 0
    BEGIN_MESSAGE_MAP(CClientSck, CAsyncSocket)
    //{{AFX_MSG_MAP(CClientSck)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    #endif // 0/////////////////////////////////////////////////////////////////////////////
    // CClientSck member functionsextern void SetData(LPCTSTR buffer);void CClientSck::OnReceive(int nErrorCode) 
    {
    ....// 在这里接受数据

    CAsyncSocket::OnReceive(nErrorCode);
    }void CClientSck::OnConnect(int nErrorCode) 
    {
    // TODO: Add your specialized code here and/or call the base class
    CAsyncSocket::OnConnect(nErrorCode);
    if(nErrorCode == 0)
    {
    ...//("SOCKET连接成功。"); }
    else
    {
    ... // ("SOCKET连接失败!");
    }
    }