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 6957279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:58:49+00:00 2026-05-27T14:58:49+00:00

With nodejs, it’s very easy to create a non-blocking TCP server. Example from nodejs.org:

  • 0

With nodejs, it’s very easy to create a non-blocking TCP server. Example from nodejs.org:

var net = require('net');
var server = net.createServer(function (socket) {
  socket.write("Echo server\r\n");
  socket.pipe(socket);
});
server.listen(1337, "127.0.0.1")

nodejs handles the select()-/poll()-/epoll() stuff for you, the socket routines and the main loop are implemented in C, so it’s very fast and efficient.

nodejs is great, but I’d like to implement a high performance TCP socket server in PHP, because I’m a PHP guy 🙂

So, one thing I already tried is to implement the socket routines in PHP, with socket_create_listen, socket_accept, socket_select etc. and the main loop in PHP. This works very well, but I don’t think it’s very efficient, because I have to use socket_select which calls the C-function select internally, but epoll would be better I think (I’m using Linux), but epoll is not available as PHP function.
(phpsocketdaemon and phpmio are 2 projects I found that implement the socket-routines for you).

Would it be possible to do it the nodejs way? I’m thinking about a PHP module that implements the loop and socket routines in C, and calls PHP callback functions for events (onread, onerror..). Or is it not worth the effort?

  • 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-05-27T14:58:50+00:00Added an answer on May 27, 2026 at 2:58 pm

    I think this is a typical case of “If all you have is a hammer, everything looks like a nail.”

    As you yourself already figured out, php is not the right tool for the job. You can probably find a way to do it anyway, but it’ll most likely be messy.

    So use the right tool for the job. You would not use a hammer to drive a screw into the wall, would you?

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

Sidebar

Related Questions

I've installed nodeJS ( from http://nodejs.org/ ). This has installed nodeJS & npm. Then
I have a nodejs TCP server and a client. Basic network communication happens. Client
I'm using nodejs to create a simple proxy server that logs http and https
The nodejs server 'gets' this JSON stream from Twitter and sends it to the
Everything in nodejs is non-blocking which is nice, but how would I go about
I have a NodeJS TCP socket server running and I'd like to add support
I have nodejs application with mongodb(mongoose). like this: var mongoose = require('mongoose'); var express
I installed nodejs from nodejs.org on my windows box. The path to node is
Nodejs Code var crypto = require(crypto); var cypher = crypto.createCipher(aes192, pass); var out =
Maybe it's just the fact that I've been using http://nodejs.org/ lately, but the lack

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.