有谁能说一下CAsyncSocket::ReceiveFrom的用法?最好有例子说明。
请高手帮我看看:
我在一个CRecUdp(继承于CSocket)类里定义了一个用来接受信息的函数,以供其他类可以调用,如下:
int CRecUdp::RecFrom(char *pBuf, int iLen)
{
return CAsyncSocket::ReceiveFrom(pBuf,iLen,m_recip,REC_PORT);
}
但编译有错,如下:
error C2664: 'int __thiscall CAsyncSocket::ReceiveFrom(void *,int,class CString &,unsigned int &,int)' : cannot convert parameter 4 from 'const int' to 'unsigned int &'
A reference that is not to 'const' cannot be bound to a non-lvalue
其中,m_recip是对方连接机器的IP,REC_PORT是对方连接机器的端号,我已定义成一个宏(#define REC_PORT 10002)。
是不是我用错了ReceiveFrom?正确的应该怎样用呢?能否给几个例子参考一下。