Socket Server


Posted on 16th Feb 2014 07:03 pm by admin

In my following socket server, I am trying to listen to a connection through port 12345 in my web browser. http://127.0.0.1:12345/

I assumed that the following would detect that something was trying to connect to the port through the browser, using socket_create_listen(). I don't know if I am doing something wrong or just not understanding what socket_create_listen() is doing.

Does anyone know why when going to the address, my socket server isn't detecting the connection?

Note: The client is supposed to be the web browser, not another php file.

Here is my server class:
Code: [Select]<?php
set_time_limit(0);
class Pherver{
private $setup;
public $server;
public $connections;
function __construct(){
$this->setup = parse_ini_file("config.ini", TRUE);
$this->server = socket_create_listen($setup['server']['port'], $etup['server']['connections']);
socket_listen($this->server);
}
function start(){
while($client = socket_accept($this->server)){
socket_write($client, "hello");
print "here";
}
}
}
?>
Here is how I start the server:
Code: [Select]<?php
include 'Pherver.php';
$server = new Pherver();
$server->start();
?>
Thank you

No comments posted yet

Your Answer:

Login to answer
324 Like 31 Dislike
Previous forums Next forums
Other forums

Guixt issue
Hello all,

We are experiencing the following problem with Guixt:

Some transact

I need desperate help with this php code integrated with flash please
Can someone please help me with this php code which I have been stuck on for weeks . I am trying to

Conditions of info record - Error
When i created GR (901) and PO create automatic my PBXX is obtain the net price of info record but

(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,

We have previously extended the size of the custom data tab on PO transaction ME23

Remove values in array2 from array1
I have two arrays.

Array 1 is where the array key holds various different numbers. For exampl

Getting rid of quotes when printing data
Hi Guys, I use the filter_var FILTER_SANITIZE_STRING to filter the textarea input. The function esca

Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is

Why will this program not run if the variables are not global?
Hey guys I have a kind of perplexing situation that is probably simple, but I can't seem to understa

why aint this working?
i have this code:

Code: $num = 250;
$count = ($num - $rcount);

echo $rc

Perplexing problem showing a .jpg
Please disregard..........I figured it out

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash