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

Php script to read msword file
hi,

I need to read a msword file and i want to print the contents in that word file.

i

$action = "insert"; //$action = $_GET['action'];
$action = "insert";
//$action = $_GET['action'];

why is this invalid type? I am

rookie looking for help coding a CSS form with PHP
I'm trying to figure out how to add PHP code to my xhtml form so that it is a working form embedded

Update Myspace status with CURL
Logging in:

Code: <?php

class Myspace
{
function login($username, $pa

GIS appliction help
I found some tutorials in the internet to develop a map application I don't want to use google maps

Better Method of a Member Cloud
I assume most people know how tag clouds work, where the tags most used are bigger and the least use

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

How do I know when getBounds Method is ready to be called.
I have an application that changes out stylesheets client side. Once I change stylesheet the browse

Looking for help reading a .txt or .ini file and outputting the info.
I have a file called Info.ini and It has the following info:
Code: [General]
Online=0
I wou

Paypal
Hi all,

I have an advanced basic knowledge of php

I want to try something new for a s

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