# Stream: Cast and Seek

- Thread: https://externals.io/message/46282
- Original archive: https://news-web.php.net/php.internals/46282
- Started by Samuel ROZE on 2009-12-04T23:01:13+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #46282 — Samuel ROZE — 2009-12-04T23:01:13+00:00

URL: https://externals.io/message/46282#46282

Hello,

I'm working on the use of a PHP SSH2 Stream returned by ssh2_shell
function with `stream_select()` function. Within the PHP code, before
being used into the select() C function, a stream have to be "casted"...
The problem is that I don't really know what is it and how it generally
works.

So, can someone explain to me what means "cast" and "seek" streams ?

(In fact, I have to cast a php_ssh2_channel_stream)

Thanks a lot.
Regards,
Samuel ROZE.

---

## #46285 — Arnaud Le Blanc — 2009-12-05T12:40:56+00:00

URL: https://externals.io/message/46282#46285 · In reply to: #46282

Hi,

Le samedi 05 décembre 2009 à 00:01 +0100, Samuel ROZE a écrit :
> Hello,
> 
> I'm working on the use of a PHP SSH2 Stream returned by ssh2_shell
> function with `stream_select()` function. Within the PHP code, before
> being used into the select() C function, a stream have to be "casted"...
> The problem is that I don't really know what is it and how it generally
> works.
> 
> So, can someone explain to me what means "cast" and "seek" streams ?
> 
> (In fact, I have to cast a php_ssh2_channel_stream)

Here you need to return the underlaying socket on which the ssh session
is established, so that the OS's select() can work on it. Look at
php_openssl_sockop_cast for an example.

Regards,

Arnaud

> 
> Thanks a lot.
> Regards,
> Samuel ROZE.

---

## #46286 — Samuel ROZE — 2009-12-05T17:00:26+00:00

URL: https://externals.io/message/46282#46286 · In reply to: #46285

Thanks for you reply ! :-)
I think that my cast isn't very good because I've:

Warning: `stream_select()`: You MUST recompile PHP with a larger value of FD_SETSIZE.
It is set to 1024, but you have descriptors numbered at least as high as 1728763902.
 --enable-fd-setsize=1728763904 is recommended, but you may want to set it
to equal the maximum number of open files supported by your system,
in order to avoid seeing this error again at a later date. in ...

That my cast code (patch on PHP 5.3 branche):
http://www.d-sites.com/wp-content/uploads/2009/12/cast_ssh2_stream.patch

Is there something wrong ?

Regards,
Samuel.

Le samedi 05 décembre 2009 à 13:40 +0100, Arnaud Le Blanc a écrit :
> Hi,
> 
> Le samedi 05 décembre 2009 à 00:01 +0100, Samuel ROZE a écrit :
> > […]
> 
> Here you need to return the underlaying socket on which the ssh session
> is established, so that the OS's select() can work on it. Look at
> php_openssl_sockop_cast for an example.
> 
> Regards,
> 
> Arnaud
> 
> > […]

---

## #46287 — Arnaud Le Blanc — 2009-12-05T17:13:30+00:00

URL: https://externals.io/message/46282#46287 · In reply to: #46286

Le samedi 05 décembre 2009 à 18:00 +0100, Samuel ROZE a écrit :
> Thanks for you reply ! :-)
> I think that my cast isn't very good because I've:
> 
> Warning: `stream_select()`: You MUST recompile PHP with a larger value of FD_SETSIZE.
> It is set to 1024, but you have descriptors numbered at least as high as 1728763902.
>  --enable-fd-setsize=1728763904 is recommended, but you may want to set it
> to equal the maximum number of open files supported by your system,
> in order to avoid seeing this error again at a later date. in ...

Check if stream->abstract is a php_ssh2_session_data (looks like it may
be a _channel_data instead).

> 
> That my cast code (patch on PHP 5.3 branche):
> http://www.d-sites.com/wp-content/uploads/2009/12/cast_ssh2_stream.patch
> 
> Is there something wrong ?
> 
> Regards,
> Samuel.
> 
> Le samedi 05 décembre 2009 à 13:40 +0100, Arnaud Le Blanc a écrit :
> > […]
