精华内容
下载资源
问答
  • WSAGetLastError返回0

    千次阅读 2013-01-09 14:37:38
    最近使用wince开发的socket连接公网IP,发现一些情况下调用WSAGetLastError返回的结果为0,而0是socket正常的标志,而明明SOCKET_ERROR == nRet了,具体发现一部分调用返回10065之类的,而一部分返回0.后终于找到...
    最近使用wince开发的socket连接公网IP,发现一些情况下调用WSAGetLastError返回的结果为0,而0是socket正常的标志,而明明SOCKET_ERROR == nRet了,具体发现一部分调用返回10065之类的,而一部分返回0.后终于找到原因:int err=WSAGetLastError();的调用必须放到其他系统函数调用之前,也就是说,出现错误后,第一时间存储WSAGetLastError结果,而不能调用其他函数之后再调用此函数。因为调用系统函数会清除WSAGetLastError,致使结果返回0.
    
    展开全文
  • socket创建失败,WSAGetLastError返回0,偶尔会出现这样正常吗? DWORD _stdcall thread(LPVOID lp) { SOCKET _socket; _socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (SOCKET_ERROR ==...
  • 问题现象:今天写一个socket服务端,客户端connect成功,服务端accept成功,能接收... ret1= send(sd, buf, 4, 0); ret2 =WSAGetLastError(); ret1返回-1,ret2返回10057,网上说10057是未连接,但的确是连接了,...

    问题现象:今天写一个socket服务端,客户端connect成功,服务端accept成功,能接收到服务端数据,但就是发送给客户端数据时send返回-1。

    网上查了查用 WSAGetLastError

     ret1= send(sd, buf, 4, 0);
     ret2 =WSAGetLastError();

    ret1返回-1,ret2返回10057,网上说10057是未连接,但的确是连接了,郁闷!

    后来突然发现send的第一个参数填错了,第一个应该是accept的返回值,而不是创建socket的返回值,修改后ret1返回4,ret2返回0.

    百科上这样说明:

    向一个已连接的套接口发送数据。

    #include <winsock.h>

    int PASCAL FAR send( SOCKET s, const char FAR* buf, int len, int flags);

    s:一个用于标识已连接套接口的描述字。

    buf:包含待发送数据的缓冲区

    len:缓冲区中数据的长度。

    flags:调用执行方式。

    展开全文
  • 最近使用wince开发的socket连接公网IP,发现一些情况下调用WSAGetLastError返回的结果为0,而0是socket正常的标志,而明明SOCKET_ERROR == nRet了,具体发现一部分调用返回10065之类的,而一部分返回0.后终于找到...

    最近使用wince开发的socket连接公网IP,发现一些情况下调用WSAGetLastError返回的结果为0,而0是socket正常的标志,而明明SOCKET_ERROR == nRet了,具体发现一部分调用返回10065之类的,而一部分返回0.后终于找到原因:int err=WSAGetLastError();的调用必须放到其他系统函数调用之前,也就是说,出现错误后,第一时间存储WSAGetLastError结果,而不能调用其他函数之后再调用此函数。因为调用系统函数会清除WSAGetLastError,致使结果返回0.

    手机csdn发布文章后无法返回问题:先点文章编辑的返回,再点最左上角整个页面的返回。

    展开全文
  • 为什么会这样?我发送的数据很大,缓冲区一般都是满的 跟这个会有关系吗?
  • int err = WSAGetLastError(); if(err != WSA_IO_PENDING){ SetErrorString(_T("IO_TYPE_ACCEPT出错!")); return FALSE; } } pHandleData->pIOData = pIoData; return TRUE; }
  • WSAGetLastError()返回

    千次阅读 2013-12-09 12:15:23
    WSAGetLastError()返回码 Socket error 0 - Directly send error Socket error 10004 - Interrupted function call Socket error 10013 - Permission denied Socket error 10014 - Bad address

    WSAGetLastError()返回码

    Socket error 0 - Directly send error

    Socket error 10004 - Interrupted function call

    Socket error 10013 - Permission denied
    Socket error 10014 - Bad address
    Socket error 10022 - Invalid argument
    Socket error 10024 - Too many open files
    Socket error 10035 - Resource temporarily unavailable
    Socket error 10036 - Operation now in progress
    Socket error 10037 - Operation already in progress
    Socket error 10038 - Socket operation on non-socket
    Socket error 10039 - Destination address required
    Socket error 10040 - Message too long
    Socket error 10041 - Protocol wrong type for socket
    Socket error 10042 - Bad protocol option
    Socket error 10043 - Protocol not supported
    Socket error 10044 - Socket type not supported
    Socket error 10045 - Operation not supported
    Socket error 10046 - Protocol family not supported
    Socket error 10047 - Address family not supported by protocol family
    Socket error 10048 - Address already in use
    Socket error 10049 - Cannot assign requested address
    Socket error 10050 - Network is down
    Socket error 10051 - Network is unreachable
    Socket error 10052 - Network dropped connection on reset
    Socket error 10053 - Software caused connection abort
    Socket error 10054 - Connection reset by peer
    Socket error 10055 - No buffer space available
    Socket error 10056 - Socket is already connected
    Socket error 10057 - Socket is not connected
    Socket error 10058 - Cannot send after socket shutdown
    Socket error 10060 - Connection timed out
    Socket error 10061 - Connection refused
    Socket error 10064 - Host is down
    Socket error 10065 - No route to host
    Socket error 10067 - Too many processes
    Socket error 10091 - Network subsystem is unavailable
    Socket error 10092 - WINSOCK.DLL version out of range
    Socket error 10093 - Successful WSAStartup not yet performed
    Socket error 10094 - Graceful shutdown in progress
    Socket error 11001 - Host not found
    Socket error 11002 - Non-authoritative host not found
    Socket error 11003 - This is a non-recoverable error
    Socket error 11004 - Valid name, no data record of requested type
    WSAEADDRINUSE (10048) Address already in use
    WSAECONNABORTED (10053) Software caused connection abort
    WSAECONNREFUSED (10061) Connection refused
    WSAECONNRESET (10054) Connection reset by peer
    WSAEDESTADDRREQ (10039) Destination address required
    WSAEHOSTUNREACH (10065) No route to host
    WSAEMFILE (10024) Too many open files
    WSAENETDOWN (10050) Network is down
    WSAENETRESET (10052) Network dropped connection
    WSAENOBUFS (10055) No buffer space available
    WSAENETUNREACH (10051) Network is unreachable
    WSAETIMEDOUT (10060) Connection timed out
    WSAHOST_NOT_FOUND (11001) Host not found
    WSASYSNOTREADY (10091) Network sub-system is unavailable
    WSANOTINITIALISED (10093) WSAStartup() not performed
    WSANO_DATA (11004) Valid name, no data of that type
    WSANO_RECOVERY (11003) Non-recoverable query error
    WSATRY_AGAIN (11002) Non-authoritative host found
    WSAVERNOTSUPPORTED (10092) Wrong WinSock DLL version
    展开全文
  • 就是在线程里 GetQueuedCompletionStatus 返回都是0WSAGetLastError() = 998 创建代码: m_hCompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1); if (NULL == m_hCompletionPort)...
  • 1:windows下C++网络编程,发送组播报文,sendto()函数发送失败,WSAGetLastError()返回错误码为5 2:代码如下: // WinsockServer_1.cpp : Defines the entry point for the console application. // #...
  • socket返回SOCKET_ERROR但是errno为0

    千次阅读 2017-02-24 20:23:15
    Because you are working with Windows sockets, you will need to use the WSAGetLastError() function to check the error code.
  • accept函数直接返回-1

    千次阅读 2018-04-20 14:02:39
    WSAGetLastError()返回0x0000271e;TCHAR* buffer = NULL;::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, wsaerror, 0, (LPTSTR)&amp;buffer, 0, NULL);得到消息为"...
  • if (sendto(bcSocket, (char *)&data[sendLen - dataLen], dataLen, 0, reinterpret_cast*>(&addrbc), nlen) == SOCKET_ERROR) { errCode = WSAGetLastError(); closesocket(bcSocket); printf("%s:...
  • 下面的connect 返回100064,按照msdn说法,如果填port,需要什么sdp “Using the port member instead of the serviceClassId member requires the application to perform its own service (SDP) search before ...
  • int temp1 = WSAGetLastError(); printf("receive data error"); return -1; } //backData = (unsigned char*)tempBuf; string backStr = "recv data from server "; backStr += tempBuf; //backData = ...
  • SOCKET serSocket = socket(AF_INET, SOCK_STREAM, 0);//创建了可识别套接字 //需要绑定的参数 SOCKADDR_IN addr; addr.sin_family = AF_INET; addr.sin_addr.S_un.S_addr = htonl(INADDR_ANY);//ip地址 addr...
  • 在客户端输入两个数字,发送到服务器端,服务器接收后进行在做和运算,将结果返回给客户端,但现在无法接收到返回数据。客服端连接是没有问题的。 代码如下: 服务端 SOCKET AcceptSocket; sockaddr_in ...
  • int temp1 = WSAGetLastError(); printf("receive data error"); return -1; } //backData = (unsigned char*)tempBuf; string backStr = "recv data from server "; backStr += tempBuf; //backData = ...
  • unsigned long cksum = 0; while (size > 1) { cksum += *buff++; size -= sizeof(USHORT); } if (size) { cksum += *(UCHAR*)buff; } // 将cksum的高16位和低16位相加,取反后得到校验和 cksum = ...
  • SOCKS5协议成功后,发送数据收不到返回信息是什么情况 ![图片说明](https://img-ask.csdn.net/upload/201811/28/1543416049_625278.png) 我是HOOK的一个棋牌游戏的 ws2_32.connect,然后在里面调用...
  • 非阻塞socket,recv返回-1,WSAGetLastError返回WSAEWOULDBLOCK,无法判断对方是否宕机(因为网络繁忙的时候或者对方没有发送数据的时候也会返回WSAEWOULDBLOCK),此时需要使用其他方法来判断网络是否断开: ...
  • int err= WSAGetLastError(); PrintInfo("\r\nWSAIoctl() error: %d", err ); closesocket(recSocket); recSocket = INVALID_SOCKET; ::WSACleanup(); nNetOK = -1; return -5; } } ```
  • 如果连接已中止,返回0。否则的话,返回SOCKET_ERROR错误,应用程序可通过WSAGetLastError()获取相应错误代码。 如无错误发生,listen()返回0。否则的话,返回SOCKET_ERROR错误,应用程序可通过WSAGetLastError()...
  • 函数返回时,大多数Windows Sockets 2函数都不会返回错误的具体原因。... 对于返回句柄的Winsock函数,返回值INVALID_SOCKET(0xffff)表示错误,并且可以通过调用WSAGetLastError来检索特定错误号。 ...
  • WINDOWS网络API总结

    千次阅读 2018-06-16 20:58:23
    一:WinSock APIWSAStartup,getaddrinfo,socket,connect,send,recv,WSAGetLastError二:WinINet APIInternetOpen:初始化一个应用程序,以使用 WinINet ...如果返回0。要InternetCloseHandle释放这个句柄Int...
  • windows网络基础

    2021-05-02 09:08:37
    调用成功后,WSAIoctl ()函数返回0。 否则的话,将返回SOCKET_ERROR错误, 应用程序可通过WSAGetLastError()来获取相应的错误代码 int WSAAPI WSAIoctl( SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, ...
  • WSACleanup 清理,成功返回0,可用WSAGetLastError来获取错误码。在多线程环境中,调用此函数将终止所有线程的套接字。 int WSACleanup(void); Return value The return value is zero if the operation was ...
  • 本文介绍Socket编程中用到的函数 ①WSAStartup()int WSAStartup(WORD wVersionRequested, //请求的版本,可由函数MAKEWORD生成 LPWSADATA lpWSAData //[out],...该函数成功返回0,否则可用 int WSAGetLastError(vo
  • 本文转自http://bbs.sjtu.edu.cn/bbscon?board=VC&file=M.895951932.A 被调用,且WINDOWS套接口实现不应yield。...如果超时则返回0;否则的话,返回SOCKET_ERROR错误,应用程序可通过WSAGetLastError()获取相应错误代
  • ret = send(socket, buffer, desLen, 0); ret返回 -1; errorNo = WSAGetLastError(); errorNo 返回 10035: 非阻塞模式遇到这个错误是正常的 [code="C"] int tryTime = 100;//重发10秒钟 ...

空空如也

空空如也

1 2 3
收藏数 44
精华内容 17
热门标签
关键字:

wsagetlasterror返回0