Coder Social home page Coder Social logo

swoole_udp_push_mind's Introduction

一个关于UDP推送的想法

为了省电,为了支持更多客户端,为了节省连接资源……

废话省略一万字。

仍然是基于C/S模型 swoole框架

  1. 客户端首先向服务端发送一个消息,表示自己想“连接”(当然是连接不鸟的,因为是UDP)。
  2. 服务端接收到客户端的信息报文,我们可以拿到 客户端的 IP PORT ,然后存到一张注册表中 。
  3. 如果服务端接收报文成功会给客户端回复一个消息,表示“我愿意为您服务,sir”,此时客户端收到之后就阻塞在这里等待读取服务端的消息。
  4. 如果客户端网络环境变化,掉线等等情况出现,那么客户端要再次连接服务端注册自己的身份。

代码实现php + swoole

代码关键词

socket读写 stream_socket_client fwrite fread swoole_table swoole_server

客户端的socket要死循环读,客户端心跳周期要考虑,目前还没做心跳机制

swoole_udp_push_mind's People

Stargazers

胖纸囧 avatar

Watchers

James Cloos avatar xxx 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.