Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:45:03+00:00 2026-06-16T14:45:03+00:00

I have a php socket server that I use to handle messages from a

  • 0

I have a php socket server that I use to handle messages from a modem. I want to create a php websocket server and whenever I receive a message from the modem I send it to a webclient. I’m a couple days trying to do it without success.

How is the best way to do it? Thanks

.

Here is the way I want to do:

Modem ------> PHP Socket Server ------> Web Clients
                    v
                 database

But if you have another best way to do it, tell me.

Thankyou again.

 

 

EDITED: This is an alternative for socket_read errors in non-blocking socket:
http://php.net/manual/pt_BR/function.socket-read.php#73509

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:45:04+00:00Added an answer on June 16, 2026 at 2:45 pm

    You can do it with non-blocking socket and long polling technique.

    The workflow is something like this.

    1. PHP connects to Modem with a non-blocking socket.
    2. Web client sends a long polling http request which times out after 5 or 10 minutes.
    3. PHP made the incoming client connection as non-blocking. This way PHP adds every client to a queue.
    4. PHP iterates over each of the clients and modem and check if something could be written or read.
    5. if there is something to read from Modem it reads and process. If necessary message is written to Webclient socket.
    6. Same as step 5 but goes from web client socket to modem socket.
    7. Do any additional work.
    8. GO to step 3.

    I had a similar situation months ago. I had to keep web sessions in PHP and there was another server which PHP was connected too. Couldn’t finished it. Later I had to move to Python for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a socket server in php server.php $master = WebSocket(localhost,800); $sockets = array($master);
Let's say I have a server at www.myhost.com. From there by using php I
I'm currently developing a PHP application that is going to use websockets for client-server
i've tried to build a socket server in php, but found out that because
I have me a socket created in PHP that I am connecting to in
I'm planning the development of a server written in PHP that can service socket
I have a PHP process that does a bunch of stuff and I want
I'm trying to create a left > php socket-server < right relation with php
Hi all Im building a android application that requires data from a PHP server.
I have a PHP script that needs to run from command line. One of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.