Using select() with STDIN on windows? [duplicate]

2019-06-25 04:36发布

This question already has an answer here:

Coming from a linux background, I'm used to the concept that everything is a file, i.e. sockets AND stdin.

This makes it easy to write a simple server/client using select(), where I include STDIN in the fdset so it'll allow me to use the terminal for input, especially for debugging.

Moving to windows however, the concept of "everything is a file" does not hold anymore. using select() for stdin (even after defining STDIN_FILENO as 0) simply doesn't work.

What's the best way to port a code using select() (for both stdin and actual sockets) to work on windows?

1条回答
【Aperson】
2楼-- · 2019-06-25 05:22

You really answered the question (in part) already. The rules for sockets on Windows and Linux are similar (as far as concept) but not the exactly the same.

Here is a link that discusses porting Windows to Linux.

And here is one porting Linux to Windows. (read the links in the bottom post.)

查看更多
登录 后发表回答