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
SCRIPT ERROR
Here is the CONTACT FORM I made for our website:
<form id="form1" name="
Slashes
Have a small problem and I'm not able to understand why I'm getting the results I'm getting... and i
Accessing Infotype data in dialog program
Hi All
In Dialog programs attributes I didn't see any logical database field. How can I access
getting rid of quotes in strings
sick of trying to deal with them in multiple ways (entering in and taking from database, echoing, ec
Change image filetype on upload?
Hi,
I've got a form which uploads an image to the server.
Is it possible to change the image t
IIS on 2003 anon access disabled issue
I have an IIS server that belongs to a domain, and anonymous access is turned off for all my sites.
Select question
Hi,
First I would like to say that php is pretty new for me..
so please don't shoot me if
quick basic question, hopefully not dumb
I don't know how to search for this, so forgive me if it's been covered...
I often see an exa
updating a single value to multiple non consecutive rows
I need to update the same value to multiple non consecutive rows. I need to add an experation date t
Extending Exception to contain method name
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a