Re: Networking and special characters.

From: Date: Tue, 16 Dec 2003 15:25:00 +0000
Subject: Re: Networking and special characters.
References: 1 2 3 4 5  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4303@lists.php.net to get a copy of this message
I have sussed this now thanks to the help of Robert Oldroyd. The trick is to use socket_select() before socket_read(). Using socket_select is much more efficient and will not hang the program. Adam "Sky" <loner@psknet.com> wrote in message news:20031108211506.23517.qmail@pb1.pair.com... > What code are you using to CONNECT to it? It would hang, if you did a while > loop. I advise using gtk::timeout_add() with around a 500-1000 MS timeout, > that checks for if($con = sockaccept()) etc. Look up timeout add in misc gtk > functions refference. > "Adam Jimenez" <adam@bantha.co.uk> wrote in message > news:20031108170550.43383.qmail@pb1.pair.com... > > Ok, I'm trying to use this function to listen for connections: > > > > function listen() > > { > > global $label,$sock; > > > > $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); // Create our > > socket. > > socket_bind($socket,'localhost',1337); //bind the socket to our IP > address, > > on port 1337. > > socket_listen($socket); // listen for any incoming connections > > while($connection = socket_accept($socket)) // accept any incoming > > connection and write to the socket. > > { > > socket_write($connection,'You\'ve successfully connected to my > > computer!\r\n'); > > } > > > > } > > > > Everything seems fine until it gets to 'socket_accept($socket)'. > > The program then hangs. > > > > What am I doing wrong? > > > > Thanks, > > > > Adam

« previous php.gtk.general (#4303) next »