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
10
Other forums
While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess
How can use this array as a key?
Say I have this array for example:
print_r($array);
Prints:
Code: [Select]Array
Multi-user card game
I'm writing a batch of games and such. Lottery is finished, Poker,blackjack,etc are next. They will
BB_Code error
I'm having a problem with a custom built function and keep getting this error:
Warning: M
downloading a file as HTML
Hi.
I'm rather confused with forcing a download. I just want to save dynamic content (from $_SESS
Simple MySQL query...
Hello,
How could I do a mysql query that does this: SELECT * WHERE date/time < 5minutes ag
Allegro crashes when running load_bitmap. Why?
I can not get Allegro to load any BMP images. Here is a section of test code. The picture is in the
get multiple rows
Hi I want to get multiple rows from a db
I am using this for the db query
Code: public
PHP FTP connect doesn't work with correct login
Hi!
i am working on this test code:
Quote<?php
$ftp_ser
with clause
hi all, i have a big query that usually access the same table more than once. for example, i have s