Socket Server Response Headers


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

Earlier I had a post about my Socket Server, I wasn't able to get it to connect, now I can

I am using socket_write() to well hopefully send html to a web page, the problem I think is that I have to send Response Headers, but I am not sure how to do that. Is that what I need to do? Currently the page just sits there and loads, it connects to the sockets, but nothing ever shows up on the page, so that is why I think I also have to send response headers... Is that correct?

Did you know?Explore Trending and Topic pages for more stories like this.
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($this->setup['server']['port'], $this->setup['server']['connections']);
if(!$this->server){
echo socket_last_error();
}
if(!socket_listen($this->server)){
echo socket_last_error();
}
echo "Pherver Service Started!n";
echo "Listening on port: ".$this->setup['server']['port']."n";
}
function start(){
while(TRUE){
$client = socket_accept($this->server);
if(!$client){
echo socket_last_error();
}else{
$msg = "<html><body><h1>Hello</h1></body></html>";
socket_write($client, $msg);
}
}
}
}
?>
No comments posted yet

Your Answer:

Login to answer
212 Like 10 Dislike
Previous forums Next forums
Other forums

b+ tree
Hi
can every body help me about b+ tree ?(insert & delete)

! = ''
In the following 'IF' statement if v_ompcat = PU for example then Oracle equates that 'IF' statement

Writting a script to arrange images........ need some help
Ok so here is the link

http://hmtotc.com/dev/projects/vrassociates/jeweler_dev/admin/index.ph

convert static html data into dynamic
hi all

i need to convert a website which has static above 2000 articles into dynamic and add

Call to undefined function mysql_fetch_accoc()
New to php/mysql coding. What's wrong with this sequence, or am I
just not seeing to obvious?

How to login with SAPCPIC userid
I have changed the Password for SAPCPIC in Development Server for 000,001 and 100 client.
But w

Find occurences of unicode characters in string
I need to prohibit filenames with everything but English characters and numbers but regexp and strin

help with database debug pls
Parse error: syntax error, unexpected T_ELSE in /home/content/m/e/s/mesick/html/students/05/php/chec

Problem with coding MySQL query
I'm having heaps of trouble getting one of my PHP/MySQL queries to work for some reason (and the fun

Unique Visitor Tracking
Hello. Currently, I run a voting site where voters are tracked by their IP address and can only vote

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