GithubHelp home page GithubHelp logo

-net_io's Introduction

-net_IO

基本网络IO模型 主要针对多路IO复用模型

1. select 模型

select 会不断轮询所负责的所有socket,当某个socket有数据到达了,通知用户进程。
select 接口原型:

FD_ZERO( fd_set * fds);/*清零*/
FD_SET(int fd, fd_set * fds);/*将fd加入fds中*/
FD_ISSET(int fd, fd_set * fds);/*如果fd在fds中,则为真*/
FD_CLR(int fd, fd_set * fds);/*将fd从set中清除*/
int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, struct timeval *timeout);
//nfds:所有文件描述符的最大值加一;readfds:监视文件描述符的读变化;writefds:监视文件描述符的写变化;
//errorfds:监视文件错误异常;
//timeout:select的超时异常,设为NULL,将select设为阻塞状态;设为0,非阻塞函数;大于0,表示等待的超时时间

使用select函数循环读键盘输入
使用select函数循环读键盘输入,select中设置超时时间
用select提高服务器的处理能力
相应的客户端

2.poll函数  

#include <poll.h>
int poll(struct pollfd * fds, unsigned int fds, int timeout);

使用poll函数的TCP服务器
使用poll函数的TCP客户端

-net_io's People

Contributors

liuchenjane avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.