Re: [PHP] sockets (long)

2001-04-06 Thread Joseph Blythe

Yasuo Ohgaki wrote:

 set_nonblock() is in PHP C source, but not in the PHP Manual. May be it's dead?
 
 It seems it take one parameter (file descriptor), let us know if it works. I
 might want to use it in the future :)


Yasuo,

There is one mention of set_nonblock() in the manual under 
accept_connect() under the socket functions. I believe that the new 
socket functions non blocking mode is dead in the current version of php 
at least under linux.

Regards,

Joseph




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] sockets (long)

2001-04-05 Thread Yasuo Ohgaki

set_nonblock() is in PHP C source, but not in the PHP Manual. May be it's dead?

It seems it take one parameter (file descriptor), let us know if it works. I
might want to use it in the future :)


From socket.c

529 /* {{{ proto bool set_nonblock(int fd)
530Sets nonblocking mode for file descriptor fd */
531 PHP_FUNCTION(set_nonblock)
532 {
533 zval **fd;
534 int ret;
535
536 if (ZEND_NUM_ARGS() != 1 ||
537 zend_get_parameters_ex(1, fd) == FAILURE) {
538 WRONG_PARAM_COUNT;
539 }
540 convert_to_long_ex(fd);
541
542 ret = fcntl(Z_LVAL_PP(fd), F_SETFL, O_NONBLOCK);
543
544 RETURN_LONG(((ret  0) ? -errno : ret));
545 }
546 /* }}} */

Hope this helps.

--
Yasuo Ohgaki


"Joseph Blythe" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Plutarck wrote:

  Very recently (a few days at most ago) someone was complaining about the
  problem you are having.
 
  According to them they can't get the socket function to accept socket
  nonblocking.
 
  It would seem that the function is broken, so you can't set nonblocking to a
  valid value at the current time.
 
  Hopefully it will be fixed in 4.0.5, due out in a few days.


 It was probaly me as I posted a message about this a few days ago ;-)

 I really hope that it does get fixed in 4.0.5

 Oh well as they say !@#$ happens,

 Thanks,

 Joseph



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] sockets (long)

2001-04-04 Thread Joseph Blythe

Hey all,

People who have been recieving this list for a while may remember me 
going through all this a while back, so I am not really a newbie when 
using sockets. I am basically trying to rewrite my Online Credit Card 
Verification (OCV) client with the new socket functions.

In thoery the following should work:

--- example1 socket functions 

$socket = socket(AF_INET, SOCK_STREAM, 0);
$conn = connect($socket, some_ip_address, some_port);
set_nonblock($socket);

$packet = "a  request";
write($socket, $packet, some_length);

$start = time();
$buffer = "";

while ( empty($buffer)  (time()  $start + 30 )) {
read($socket, $buffer, some_length);
}
This does not work will hang until the script times out (max execution 
time is exceeded).

- exampe 2 network and file system functions -

$socket = fsockopen (some_address, some_port, $errno, $errstr, 30);
set_socket_blocking($socket, 0);

$packet = "a request";
fputs ($socket, $packet);

$start = time();

while ( empty($buffer)  (time()  $start + 30 )) {
$buffer = fgets($socket, some_length);
}

Works! After 30 seconds fgets is timed out.

The lengths I am reading and writing are correct as all request and 
response lengths are pre-determined.

I cannot use set_socket_blocking($socket, 0) in example 1 instead of 
set_nonblock($socket) as it will generate an errora s follows:

Warning: Supplied argument is not a valid File-Handle resource ...

I believe that in example 1 the socket is not being set to nonblock mode?

Can anyone verfiy this, give me a better way, or maybe just put me out 
of my misery :-)

Regards,

Joseph








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] sockets (long)

2001-04-04 Thread Joseph Blythe

Plutarck wrote:

 Very recently (a few days at most ago) someone was complaining about the
 problem you are having.
 
 According to them they can't get the socket function to accept socket
 nonblocking.
 
 It would seem that the function is broken, so you can't set nonblocking to a
 valid value at the current time.
 
 Hopefully it will be fixed in 4.0.5, due out in a few days.


It was probaly me as I posted a message about this a few days ago ;-)

I really hope that it does get fixed in 4.0.5

Oh well as they say !@#$ happens,

Thanks,

Joseph



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]