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

C++ API to Oracle dB
I need to perform a select command to the Oracle dB to obtain information from a table.
What libr

SCRIPT ERROR
Here is the CONTACT FORM I made for our website:

<form id="form1" name="

have trouble in a if condition
The if below is working ok, it check when indexes, name, zipcode and state are empty.
Code: &

"From field" in PHP email form
I used a wizard to create a PHP email form. I was able to customize it with the exception of the Fr

Mail form doesn't send Russian/Cyrillic characters correctly?
When someone enters foreign characters (like Cyrillic text, and Japanese/Chinese probably gives the

help understanding hidden input w/ php
hello i'm doing a tutorial where there are multiple forms for an edit page for a user to update thei

HTAccess auto log in?
Hi all.

Too busy driving celebs about lately so I hope someone here can help me out.

I

Call Screen statement Error
Dear Experts,

is there any setting that needs to be done before creating any dialog progr

Display the user's weight lost in the past week
Hello everyone,

I am working on a weight loss app for my site, and I want to display the user

a very simple php header question (sorry!)
Firstly...I do apologise if this annoys anyone....a header error

I'm do not know php &

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