| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 902 人关注过本帖
标题:Winsock 大神有没有,求助一个问题
只看楼主 加入收藏
NiuYoohoo
Rank: 4
等 级:业余侠客
威 望:2
帖 子:65
专家分:216
注 册:2016-10-8
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:6 
Winsock 大神有没有,求助一个问题
在看RTSP 协议的时候有个问题 就是套接字的值和 [0,10000) 直接有啥关系么??

  fprintf(stderr, "socket numbers used in the select() call:");
    for (int i = 0; i < 10000; ++i) {
      if (FD_ISSET(i, &fReadSet) || FD_ISSET(i, &fWriteSet) || FD_ISSET(i, &fExceptionSet)) {
        fprintf(stderr, " %d(", i);
        if (FD_ISSET(i, &fReadSet)) fprintf(stderr, "r");
        if (FD_ISSET(i, &fWriteSet)) fprintf(stderr, "w");
        if (FD_ISSET(i, &fExceptionSet)) fprintf(stderr, "e");
        fprintf(stderr, ")");
      }
    }

图片为MSDN对socket 返回值的描述!
图片附件: 游客没有浏览图片的权限,请 登录注册

2017-04-18 17:33
NiuYoohoo
Rank: 4
等 级:业余侠客
威 望:2
帖 子:65
专家分:216
注 册:2016-10-8
收藏
得分:0 


WSA_INVALID_HANDLE
6
 

Specified event object handle is invalid.

    An application attempts to use an event object, but the specified handle is not valid. Note that this error is returned by the operating system, so the error number may change in future releases of Windows.

WSA_NOT_ENOUGH_MEMORY
8
 

Insufficient memory available.

    An application used a Windows Sockets function that directly maps to a Windows function. The Windows function is indicating a lack of required memory resources. Note that this error is returned by the operating system, so the error number may change in future releases of Windows.

WSA_INVALID_PARAMETER
87
 

One or more parameters are invalid.

    An application used a Windows Sockets function which directly maps to a Windows function. The Windows function is indicating a problem with one or more parameters. Note that this error is returned by the operating system, so the error number may change in future releases of Windows.

WSA_OPERATION_ABORTED
995
 

Overlapped operation aborted.

    An overlapped operation was canceled due to the closure of the socket, or the execution of the SIO_FLUSH command in WSAIoctl. Note that this error is returned by the operating system, so the error number may change in future releases of Windows.

WSA_IO_INCOMPLETE
996
 

Overlapped I/O event object not in signaled state.

    The application has tried to determine the status of an overlapped operation which is not yet completed. Applications that use WSAGetOverlappedResult (with the fWait flag set to FALSE) in a polling mode to determine when an overlapped operation has completed, get this error code until the operation is complete. Note that this error is returned by the operating system, so the error number may change in future releases of Windows.

WSA_IO_PENDING
997
 

Overlapped operations will complete later.

    The application has initiated an overlapped operation that cannot be completed immediately. A completion indication will be given later when the operation has been completed. Note that this error is returned by the operating system, so the error number may change in future releases of Windows.

1000以下都是异常值没错,但是这样写也太。。。
2017-04-18 17:37
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:7 
这样写有问题吗?
2017-04-18 19:49
烟雨晨曦
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:7
帖 子:150
专家分:599
注 册:2017-3-5
收藏
得分:7 
在linux 下用过 意思应该差不多,你创建的每一个socket都有一个文件描述符(相当于一个指针)记录着这个socket的所有信息(也就是一个数字 有一个范围),
你需要遍历这个范围内所有socket,是否可读或者可写,再进行对应操作。
2017-04-18 20:43
NiuYoohoo
Rank: 4
等 级:业余侠客
威 望:2
帖 子:65
专家分:216
注 册:2016-10-8
收藏
得分:0 
回复 3楼 吹水佬
总共就6个异常值,每次都遍历10000 有必要么!
2017-04-19 08:57
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:0 
以下是引用NiuYoohoo在2017-4-19 08:57:27的发言:

总共就6个异常值,每次都遍历10000 有必要么!

为何要去遍历?
2017-04-19 10:23
NiuYoohoo
Rank: 4
等 级:业余侠客
威 望:2
帖 子:65
专家分:216
注 册:2016-10-8
收藏
得分:0 
回复 6楼 吹水佬
我也想知道为何要遍历 为啥一个find_if 或者contain轻而易举的事情为何要遍历!
2017-04-19 11:41
快速回复:Winsock 大神有没有,求助一个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034572 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved