标签: posix-select

选择vs民意调查与epoll

我正在设计一个新服务器,它需要支持数千个UDP连接(大约100,000个会话).有哪些输入或建议可供使用?

sockets linux epoll posix-select

64
推荐指数
3
解决办法
5万
查看次数

socket select()与非block recv

我看过一些select()poll()or相比的文章epoll(),我看到很多指南讨论了select()多个套接字的实际用法.

但是,我似乎无法找到的是与没有阻塞的无阻塞recv()呼叫的比较select().如果只有1个套接字要读取,1个套接字要写入,是否有任何理由使用该select()呼叫?该recv()方法可以设置为WSAEWOULDBLOCK在没有可用数据的情况下不阻塞并返回错误(),那么select()当您没有其他套接字要检查时,为什么还要打扰?非阻塞recv()调用是否慢得多?

c sockets nonblocking recv posix-select

12
推荐指数
3
解决办法
8449
查看次数

当我们有poll()和epoll()时,为什么要使用select()

我看着之间的差异pollepollselect。我不知道是什么时候应该使用select。鉴于此poll,我看不到任何优势,并且epoll拥有一切,select还有更多。

c sockets posix-select

6
推荐指数
1
解决办法
1077
查看次数

使用如此多CPU功率的select()有什么问题?

我正在使用非阻塞套接字(C/C++)编写网络通信程序select.该程序非常大,所以我无法上传源代码.在非常激进的测试会话中,我使用测试代码频繁地打开和关闭TCP和UDP.总是最终一端没有响应并且CPU使用率超过98或99%.然后我用gdb来附加."bt"显示以下内容:

0x00007f1b71b59ac3 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:82
82  ../sysdeps/unix/syscall-template.S: No such file or directory.
    in ../sysdeps/unix/syscall-template.S
Run Code Online (Sandbox Code Playgroud)

它可能是什么类型的错误?

$ uname -a
Linux kiosk2 2.6.32-34-generic #77-Ubuntu SMP Tue Sep 13 19:39:17 UTC 2011 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

sockets tcp posix-select

6
推荐指数
1
解决办法
5297
查看次数

在Mac OS中无法使用Python select.poll?

$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import select
>>> select.poll
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'
Run Code Online (Sandbox Code Playgroud)

python macos networking posix-select

6
推荐指数
1
解决办法
3287
查看次数

将 select() 与管道一起使用

这个想法是创建一个二叉进程树,将信息沿着树发送,然后将值发送回树,在树上升时聚合信息。

我遇到的问题是使用来select()确定管道何时准备好读取。在我到目前为止所写的内容中,第一个管道(第一个左子管道)能够接收信息并打印它;然而,第二个管道(第一个右子管道)在接收任何信息之前超时。我不知道为什么,因为第一根管道工作得很好。

每个孩子最终都会创建自己的孩子,如果没有更好的处理,我什至无法开始这部分过程select()

int bit_count(char *passed, int len){
//initialize file descriptors
int fd1[2] = {1, 2};
int fd2[2] = {3, 4};

fd_set read_set;
fd_set write_set;

//set timeval structure for timeout
struct timeval tv;
tv.tv_sec = 10;
tv.tv_usec = 0;

FD_ZERO(&read_set);             //clear the set
FD_SET(fd1[0], &read_set);      //add first file descriptor to set
FD_SET(fd2[0], &read_set);      //add second file descriptor to set

//open the pipes
pipe(fd1);
pipe(fd2);

//fork a child process
pid_t kid = fork();
if(kid == -1) printf("forking …
Run Code Online (Sandbox Code Playgroud)

c pipe posix-select

4
推荐指数
1
解决办法
4235
查看次数

如何使用POSIX select()

Shoud我在使用它们之前使文件描述符无阻塞select()

c c++ posix posix-select

3
推荐指数
1
解决办法
1722
查看次数

使用select()函数在C语言中进行套接字编程

根据我从这个帖子得到的答案,我创建了这个:

    //Server 

    sock_init(); //from SFL, see http://legacy.imatix.com/html/sfl/

    timeout = 50000;

    serv_sock_input[0] = TCP(1234); 
    serv_sock_input[1] = UDP(9876);

    input_protocols[0] = "tcp";
    input_protocols[1] = "udp";

    while (1)
    {
        FD_ZERO(&sock_set);
        for (x = 0; x<number_of_inputs; x++)
        {
            FD_SET(serv_sock_input[x], &sock_set);
        }

        select_timeout.tv_sec = timeout;
        select_timeout.tv_usec = 0;

        if (select(0, &sock_set, NULL, NULL, &select_timeout) == 0)
            printf("No requests");
        else
        {
            for (x = 0; x<number_of_inputs; x++)
            {
                if (FD_ISSET(serv_sock_input[x],&sock_set))
                {
                    printf("\nRequest on port %d: \n", x);
                    if ((strcmp(input_protocols[x],"tcp")) == 0) //in this case, 0 …
Run Code Online (Sandbox Code Playgroud)

c sockets posix-select

2
推荐指数
1
解决办法
9122
查看次数

C select()函数是否已被弃用?

我正在读一本关于C中网络编程的书.它是从2004年开始的.在示例代码中,作者使用select C函数接受来自客户端的多个连接.这个功能今天已被弃用吗?

我看到有不同的方法可以接受多边形I/O,比如pollepoll.有什么好处?

c io posix-select

2
推荐指数
1
解决办法
596
查看次数

使用FD_SET进行读写集以在C中发送和接收数据

我有一个客户端和服务器,客户端运行一个select循环以在TCP和UDP连接之间进行多路复用。我正在尝试将我的TCP连接文件描述符同时添加到readwrite集中,然后使用writeset和1使用readset 发起一个消息交换。我与设备的消息通信write正常,但与read设备无法通信。

客户代码:

    char buf[256] = {};
    char buf_to_send[256] = {};
    int nfds, sd, r;
    fd_set rd, wr;
    int connect_init = 1;

/* I do the Connect Command here */

    FD_ZERO(&rd);
    FD_ZERO(&wr);

    FD_SET(sd, &rd);
    FD_SET(sd, &wr);

    nfds = sd;


    for(; ;){

       r = select(nfds + 1, &rd, &wr, NULL, NULL);

       if(connect_init == 0){

          if(FD_ISSET(sd, &rd)){    // this is not working, if I change rd to wr, …
Run Code Online (Sandbox Code Playgroud)

c sockets loops posix-select

1
推荐指数
1
解决办法
4967
查看次数

标签 统计

posix-select ×10

c ×7

sockets ×6

c++ ×1

epoll ×1

io ×1

linux ×1

loops ×1

macos ×1

networking ×1

nonblocking ×1

pipe ×1

posix ×1

python ×1

recv ×1

tcp ×1