RE: [PHP] how to close a socket output, leave input

2006-12-08 Thread Mustafa Aras Koktas
Is this for the client application or server?
I assume it is a client as you are trying to read a server response.
socket_write() will return the length of the buffer that is written to
server, so you can check that value to make sure the send is complete.

--Aras

-Original Message-
From: nick.yim [mailto:[EMAIL PROTECTED]
Sent: Friday, December 08, 2006 3:39 AM
To: php-general
Subject: [PHP] how to close a socket output, leave input


Hello All,

1. create a socket
2. write something
3. (just) close output
4. read the server response
5. close the socket

step 3, i mean close output, let the server know the client send
complete

Best regards,

nick.yim
[EMAIL PROTECTED]
2006-12-08

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] signal handling

2006-12-08 Thread Mustafa Aras Koktas
Roman, Stut and Jochem, thanks for the comments and recommendations on the
subject.
I have installed my signal as  pcntl_signal(SIGCHLD, SIG_IGN)  without a
specific function handler and it is closing child processes now. I could not
use the pcntl_wait because it is available after PHP 5.0 i guess.



-Original Message-
From: Roman Neuhauser [mailto:[EMAIL PROTECTED]
Sent: Friday, December 08, 2006 7:02 PM
To: Jochem Maas
Cc: php-general@lists.php.net
Subject: Re: [PHP] signal handling


# [EMAIL PROTECTED] / 2006-12-08 15:36:52 +0100:
 Roman Neuhauser wrote:
  # [EMAIL PROTECTED] / 2006-12-02 02:01:35 +0200:
  [...] to write a simple socket server in PHP. My current example just
  prints the same character, you send to server from keyboard. It is
  successfull in forking, and generates child as people connect. However
in
  any way the client exits, the child process remains defunct on system.

  The parent needs to wait(2) for its children.
http://php.net/pcntl_wait

 have I understood correctly that using pcntl_wait() means you can't do
anything in
 the parent process until all children are dead?

no.

 but if it is true how do you go about tackling the signal handling in
child processes
 AND at the same time have the parent process do something useful like ...
 interact/direct child processes, do other management tasks whilst child
processes are running?

do whatever you want, either have a SIGCLD handler, or check one of the
wait(2)-family functions every now and then (and make sure to use
WNOHANG).

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php