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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010

Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like

Alterar a hora do servidor
Se alguém souber, ajude-me a adicionar 6 horas, obrigado
<tr>
&

image upload, resize THEN submit form
Ok so I have a form that requires the user to upload an image, and then do something with that image

When file included, REMOTE_ADDR is server's?
I have an index file that handles my site, basically index.php?page=ip will activate "require('

Function module "DPS_CHECK_TABLE_EXISTS" not found (after OSS 1422843 impl)
Dear All,

I implemented Note OSS 1422843.

When i execute the new report RSPO20

Populate drop down list from table??
Lets say for arguments sake that i have a table which contains the numbers 1 to 10.
How can i get

Php If in MySql query (hiding labels if a field is empty)
Okay, I've been trying to do this for a while, and I'm finally going to ask for help so I can get th

Passing PHP variables from one page to another
Hello-

I'm having trouble figuring out how to transport a variable from one php file to anoth

Getting Subdomain Name With PHP?
I want to grab the subdomain name with PHP so I can generate database queries.

for example my

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