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

get the country of visitor and display content based on that
Hello all,

I have seen that Google analytics can tell you where a visitor is coming from and

Can't get the unicode character
I'm trying to get some text from various parts of a file. I have converted the file to hex (bin2hex)

how to get sn motherboard
Hello.
I want to get serial number motherboard, cpu and else hardware.
Can You show me sam

News script
Hi ...

I am not sure if this is the rite place to post this but if its not sorry

i am

What makes a script your own?
If someone finds a login script online, and changes some variable names around and some other minor

error help - Dynamic Image
I've been working on making my site less cluttered in the directories and more secure lately. In an

Echoing ASCII code
I have a php page that splits a string into chars and then echoes the ASCII code for each char. I'm

PHP Cannot redeclare class
I have 6 files, and two of them do not seem to want to play well. I keep getting a "Cannot rede

A little help needed passing hidden values to next page
I have a page that has hidden values in a form.

example
Code: <input name='signupID

Effort Estimation Template for Steady State Support
Hi Everyone,

Is there any SAP provided template/format for system change and enhancements

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