请问总是返回10035的错误该怎么办?

XiaoDi_Liu 2003-09-08 01:45:07
目标:
实现文件传输

代码:

do
{
memset(m_chTranBuffer,0,sizeof(m_chTranBuffer));
l_iReadLeng = fread(m_chTranBuffer,1,4096,m_pSourFile);
l_iSendLeng = send(m_soClient,m_chTranBuffer,l_iReadLeng,0);

if(l_iSendLeng != 4096)
{
TRACE("Read:%d Send:%d\n\n",l_iReadLeng,l_iSendLeng);
TRACE("Error:%d\n",WSAGetLastError());
}
l_iSendTotal += l_iSendLeng;
}while(l_iReadLeng == 4096);

WSAGetLastError的返回值为10035.该怎么办??
...全文
621 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
No9 2003-09-08
  • 打赏
  • 举报
回复
if(l_iSendLeng != 4096) 不对!
应该是:
if(l_iSendLeng != l_iReadLeng)!

这样就不会出现上面的错误了!
DarkShow 2003-09-08
  • 打赏
  • 举报
回复
光看到这里就应该觉得复杂了许多吧,参数从原来的3个变到了9个。呵呵,吓人吧
DarkShow 2003-09-08
  • 打赏
  • 举报
回复
其实这个函数也可以,不过是高级版本了,好像是2.0版本以上的 WinSock才可以用吧。

也复杂了许多。再看看MSDN的说明:

WSAIoctl
The WSAIoctl function controls the mode of a socket.

int WSAIoctl(
SOCKET s,
DWORD dwIoControlCode,
LPVOID lpvInBuffer,
DWORD cbInBuffer,
LPVOID lpvOutBuffer,
DWORD cbOutBuffer,
LPDWORD lpcbBytesReturned,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
);

Parameters
s
[in] Descriptor identifying a socket.
dwIoControlCode
[in] Control code of operation to perform.
lpvInBuffer
[in] Pointer to the input buffer.
cbInBuffer
[in] Size of the input buffer, in bytes.
lpvOutBuffer
[out] Pointer to the output buffer.
cbOutBuffer
[in] Size of the output buffer, in bytes.
lpcbBytesReturned
[out] Pointer to actual number of bytes of output.
lpOverlapped
[in] Pointer to a WSAOVERLAPPED structure (ignored for nonoverlapped sockets).
lpCompletionRoutine
[in] Pointer to the completion routine called when the operation has been completed (ignored for nonoverlapped sockets).
Return Values
Upon successful completion, the WSAIoctl returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.Error code Meaning
WSAENETDOWN The network subsystem has failed.
WSAEFAULT The lpvInBuffer, lpvOutBuffer, lpcbBytesReturned, lpOverlapped, or lpCompletionRoutine parameter is not totally contained in a valid part of the user address space, or the cbInBuffer or cbOutBuffer parameter is too small.
WSAEINVAL The dwIoControlCode oarameter is not a valid command, or a specified input parameter is not acceptable, or the command is not applicable to the type of socket specified.
WSAEINPROGRESS The function is invoked when a callback is in progress.
WSAENOTSOCK The descriptor s is not a socket.
WSAEOPNOTSUPP The specified ioctl command cannot be realized. (For example, the FLOWSPEC structures specified in SIO_SET_QOS or SIO_SET_GROUP_QOS cannot be satisfied.)
WSA_IO_PENDING An overlapped operation was successfully initiated and completion will be indicated at a later time.
WSAEWOULDBLOCK The socket is marked as nonblocking and the requested operation would block.
WSAENOPROTOOPT The socket option is not supported on the specified protocol. For example, an attempt to use the SIO_GET_BROADCAST_ADDRESS IOCTL was made on an IPv6 socket.
DarkShow 2003-09-08
  • 打赏
  • 举报
回复
最好的帮助MSDN上的解释

ioctlsocket
The ioctlsocket function controls the I/O mode of a socket.

int ioctlsocket(
SOCKET s,
long cmd,
u_long* argp
);

Parameters
s
[in] Descriptor identifying a socket.
cmd
[in] Command to perform on the socket s.
argp
[in, out] Pointer to a parameter for cmd.

Remarks
The ioctlsocket function can be used on any socket in any state. It is used to set or retrieve operating parameters associated with the socket, independent of the protocol and communications subsystem. Here are the supported commands to use in the cmd parameter and their semantics:



FIONBIO
The argp parameter is a pointer to an unsigned long value. Set argp to a nonzero value if the nonblocking mode should be enabled, or zero if the nonblocking mode should be disabled. When a socket is created, it operates in blocking mode by default (nonblocking mode is disabled). This is consistent with BSD sockets. argp value Nonblocking mode
0 Disabled
nonzero Enabled

The WSAAsyncSelect and WSAEventSelect functions automatically set a socket to nonblocking mode. If WSAAsyncSelect or WSAEventSelect has been issued on a socket, then any attempt to use ioctlsocket to set the socket back to blocking mode will fail with WSAEINVAL.

To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero.

FIONREAD
Use to determine the amount of data pending in the network's input buffer that can be read from socket s. The argp parameter points to an unsigned long value in which ioctlsocket stores the result. FIONREAD returns the amount of data that can be read in a single call to the recv function, which may not be the same as the total amount of data queued on the socket. If s is message oriented (for example, type SOCK_DGRAM), FIONREAD still returns the amount of pending data in the network buffer, however, the amount that can actually be read in a single call to the recv function is limited to the data size written in the send or sendto function call.
SIOCATMARK
Use to determine if all out of band (OOB) data has been read. (See Windows Sockets 1.1 Blocking Routines and EINPROGRESS for a discussion on OOB data.) This applies only to a stream oriented socket (for example, type SOCK_STREAM) that has been configured for in-line reception of any OOB data (SO_OOBINLINE). On sockets with the SO_OOBINLINE socket option set, SIOCATMARK always returns TRUE and the OOB data is returned to the user as normal data.
ypos 2003-09-08
  • 打赏
  • 举报
回复
你查一下ioctlsocket,FIONBIO
XiaoDi_Liu 2003-09-08
  • 打赏
  • 举报
回复
那在什么地方设置才可以将其设成阻塞方式的呢?谢谢!
DarkShow 2003-09-08
  • 打赏
  • 举报
回复
无法立即完成一个非阻挡性套接字操作。

你用的非阻塞方式,所以,返回这个错误是正常的。非阻塞套接字的操作,都不能立即完成,一般都返回一个这个错误。
smch 2003-09-08
  • 打赏
  • 举报
回复
10035是什么错误?

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧