发送connect后怎么知道有没有连上

我的类继承自CSocket,我希望有一个connect的返回成功或者错误码,或者其他方法,求帮助... 我的类继承自CSocket,我希望有一个connect的返回成功或者错误码,或者其他方法,求帮助 展开
 我来答
Aiscii
2012-11-07 · 超过16用户采纳过TA的回答
知道答主
回答量:63
采纳率:0%
帮助的人:51.7万
展开全部
CSocket从CAsyncSocket派生而来,Connect后判断返回的值,如果是TRUE就是成功,如果为0就是错误的,这个时候调用GetLastError获取错误码即可。
错误码如下:

WSANOTINITIALISED A successful AfxSocketInit must occur before using this API.
WSAENETDOWN The Windows Sockets implementation detected that the network subsystem failed.
WSAEADDRINUSE The specified address is already in use.
WSAEINPROGRESS A blocking Windows Sockets call is in progress.
WSAEADDRNOTAVAIL The specified address is not available from the local machine.
WSAEAFNOSUPPORT Addresses in the specified family cannot be used with this socket.
WSAECONNREFUSED The attempt to connect was rejected.
WSAEDESTADDRREQ A destination address is required.
WSAEFAULT The nSockAddrLen argument is incorrect.
WSAEINVAL Invalid host address.
WSAEISCONN The socket is already connected.
WSAEMFILE No more file descriptors are available.
WSAENETUNREACH The network cannot be reached from this host at this time.
WSAENOBUFS No buffer space is available. The socket cannot be connected.
WSAENOTSOCK The descriptor is not a socket.
WSAETIMEDOUT Attempt to connect timed out without establishing a connection.
WSAEWOULDBLOCK The socket is marked as nonblocking and the connection cannot be completed immediately.

自己也可以查下msdn。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式