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
10
Other forums
What do you call the "token" thing?
You know how some sites have links that run on tokens? Tokens are links that only stay alive for a c
what does this mean? +=
is anyone able to explain what this code is saying?
i had it written for me awhile back and n
switch form actions? not working
i want on submit to go to different pages according to the CatID
Code: <?php $CatID=$_
PHP Game
hy i was wondering what's the best method in order to make some automatic updates in a php game
<
How can I Compare two xml documents?
Hi all,
I am doing a POC for my project and I am using XE database 10g version.
Simple PHP/Java Help..
Hi,
I'm trying to build a little program to do with calculating postage. Unfortunately i haven't
Creating Images from images in PHP
Okay well I am trying to make a 'dynamic' calender image with PHP.
I have images like this:
Change Age automatically
hi guys . im new to php , is it possible to change age value in mysql automatically when year change
Javascript or not?
How many people prefer javascript/ajax sites? How many prefer the good old fashion straight php sit
Mail Form receiving emails with no content
Hi, I hope someone here can help me.
I have a simple form in my website, it was working OK, after