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?

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

need Array help
This is what I have to do.
$teamname[1] = "Red Sox"
$teamname[2] = "Gian

Stats of viewers
Hello. I have a website in php and people can login. I want to make an admin control panel where u c

Taxonomy? Classification? Categorisation?
Not sure if there is a way around this classification problem
I have a supplier who produces

TabControl Inside ListView Not Editing
Hello everybodyI have a ListView on my page. Inside the ListView I put a TabControl, cuz I want to p

Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

Help with explandable category tree
I have the below query:

SELECT l1.id as lev1_id,l2.id as lev2_id,l3.id as lev3_id,l1.categ

function not returning the correct value
I have a program that needs to return a value from a function. I have an output statement inside the

Protecting forms
Alright, I want to protect some forms of mine from SQL Injections, because I had someone earlier spa

Posting to another Site?
I have software that people install.
When they install it, is there a way to make it post their d

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