gnope php gtk gui gnope.org  

How to creat a server under PHP-GTK?

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
yahoo_webmaster



Joined: 22 May 2007
Posts: 4
Location: France

PostPosted: Tue May 22, 2007 7:52 pm    Post subject: How to creat a server under PHP-GTK? Reply with quote

Hello!!

First, sorry if I make some faults, but I'm french.

I want to make a server under PHP-GTK. I know how to make a server in PHP-CLI, but when I make an infinite while (to read connections), the GTK window freeze and I can't do nothing.

Is there any method to fix that problem? with an invisible windows for example?

My server is something like that :

Code:

<?php
// define server IP and port
$adress = "192.168.1.1";
$port = "65000";


function match_begin($string){return preg_match("#^".$string."#Usi", $GLOBALS['reception']);}

// creat the socket
$socket_to_listen = socket_create(AF_INET, SOCK_STREAM, 0);
if(socket_bind($socket_to_listen, $adresse, $port)){
   //listen to the socket
   socket_listen($socket_to_listen);
   echo "Server ready\r\n";
}else{
   echo "Can't creat the socket.\r\n";
   exit();
}
// here the infinite while
while(true){
// accept connections
$client = socket_accept($socket_to_listen);
$reception = socket_read($client , 255);
//Here the command section. I've only write the "stop" command but you can add other with a simple elseif()
if(match_begin('/stop')){
   echo "[Command] The \"Stop\" signal was received \r\n";
   exit();
}else{
   echo "[Received] ".$reception."\r\n";}
}
?>
Back to top
marc



Joined: 11 May 2006
Posts: 12
Location: Toulouse - France

PostPosted: Thu May 24, 2007 4:05 pm    Post subject: hello Reply with quote

you should have a look at Gtk::io_add_watch ; there is some comments about this on this forum, and around in php-gtk.eu site to.

hello from France (Toulouse).
Back to top
yahoo_webmaster



Joined: 22 May 2007
Posts: 4
Location: France

PostPosted: Wed May 30, 2007 2:10 pm    Post subject: Reply with quote

Thanks! I'll watch that.
[edit] Are you sure there is something on the forum? I have found nothing about Gtk::io_add_watch in this forum or on PHP-GTK website.
Back to top
marc



Joined: 11 May 2006
Posts: 12
Location: Toulouse - France

PostPosted: Mon Jun 11, 2007 12:55 pm    Post subject: a TCP server for php-gtk Reply with quote

hello,

I'm writing a small server for php-gtk. This server will be an HTTP proxy. It's not complete now, but it is usable. If you a still trying to write a server, have a look at this piece of code : http://php.classes.free.fr/php/gtk/visualProxy/
Back to top
yahoo_webmaster



Joined: 22 May 2007
Posts: 4
Location: France

PostPosted: Tue Jun 26, 2007 10:05 am    Post subject: Reply with quote

Thanks marc!

I'll watch that soon.
Back to top
marc



Joined: 11 May 2006
Posts: 12
Location: Toulouse - France

PostPosted: Mon Jul 02, 2007 1:00 pm    Post subject: Re: a TCP server for php-gtk Reply with quote

marc wrote:
... a server, have a look at this piece of code : http://php.classes.free.fr/php/gtk/visualProxy/


- now, this proxy server is very far more robust and support very well any connections in non blocking mode.
- TcpConnection is the base class to insure IO to sockets,
- there is some console examples easy to understand in tests directory.
- errors are managed with exceptions, so it very easy to handle.
- there is some notifications callbacks to notify user interface about current IO : socket opened, reading, writing, transmitted bytes ...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.