Code Monkey home page Code Monkey logo

php-multithreaded-socket-server's Introduction

php-multithreaded-socket-server's People

Contributors

cweric avatar lukaszkujawa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-multithreaded-socket-server's Issues

How to send message back to a client using IP address and PORT.

Hi i like your post. it's awesome. But i need one more help, with the help of your classes and code, i am able to setup multiple clients connection to my server, and i am saving all clients IP address and PORT in which communication is happening, now i want to send some message to specific client using there IP and PORT, so is there any way to do that, so that i can directly select any client IP and PORT which i have saved in db, and can send some required message to client form server side.

Forked childs remain active after socket connection closes

After forked child closes socket connection, the process remains opened.

$client->close();
printf( "[%s] Disconnected\n", $client->getAddress() );

So even if the connection closes, the process remains active.

Adding an exit after closing socket connection fixes this.

    $client->close();
    printf( "[%s] Disconnected\n", $client->getAddress() );

    // exit child process
    exit;

But i'm not sure if this is the correct way to do it.

Add hability to query remote ADDR:PORT

Here's a small change to SocketClient.php in order to make it able to query the remote address and port:

address = $address; $this->port = $port; $this->connection = $connection; socket_getpeername($connection, $remote_addr, $remote_port); $this->remote_addr = $remote_addr; $this->remote_port = $remote_port; } public function send( $message ) { socket_write($this->connection, $message, strlen($message)); } public function read($len = 1024) { if ( ( $buf = @socket_read( $this->connection, $len, PHP_BINARY_READ ) ) === false ) { return null; } return $buf; } public function getAddress() { return $this->address; } public function getRemoteAddress(){ return $this->remote_addr; } public function getPort() { return $this->port; } public function getRemotePort(){ return $this->remote_port; } public function close() { socket_shutdown( $this->connection ); socket_close( $this->connection ); } ``` }

Why code is checking if $this->connectionHandler is_array?

Hello,

I was looking over the following code

if( is_array( $this->connectionHandler ) ) {
$object = $this->connectionHandler[0];
$method = $this->connectionHandler[1];
$object->$method( $socketClient );
}
else {
$function = $this->connectionHandler;
$function( $socketClient );
}

And was asking why is not just

$function = $this->connectionHandler;
$function( $socketClient );

Can you give an example of a connectionHandler passed as an array?

Thanks!

New process don't die

Hi!

I tested your project and i see one problem: The new connections create a new process, but on the end connection the new process isn't destroyed, for this issue the number of process is increased and doesn't dies

Any solution?

Thanks!

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.