| Author |
Access to socket from PoCo::Server::TCP
|
|
| Rohan Almeida 2007-05-22, 10:17 pm |
|
Hi,
Is there any way I can get access to the underlying socket while
using PoCo::Server::TCP without using the Client* callbacks?
The docs say that the socket is only passed if I use the Acceptor
callback, which then means I have to create my own Wheel for
read/write and so on.
Again, $heap->{listener} is only available if I use the Acceptor
callback. $heap->{client} seems to be a ReadWrite wheel. I tried
accessing the Handle for this wheel (which should be the socket),
but I'm not getting anywhere.
Thanks,
Rohan
| |
| Matt Sickler 2007-05-22, 10:17 pm |
| There arent any documented ways to get at a ReadWrite wheel's handle.
The non-POE way you could do it (and breaking encapsulation) would be to use
$heap->{client}->[ POE::Wheel::ReadWrite::HANDLE_INPUT ] and
$heap->{client}->[ POE::Wheel::ReadWrite::HANDLE_OUTPUT ]
( those would be the same in many situations ).
This breaks encapsulation and could change at no notice and its all your fault.
A better question you need to ask is why do you need to get at the socket?
On 5/22/07, Rohan Almeida <rohan@almeida.in> wrote:
>
> Hi,
>
> Is there any way I can get access to the underlying socket while
> using PoCo::Server::TCP without using the Client* callbacks?
>
> The docs say that the socket is only passed if I use the Acceptor
> callback, which then means I have to create my own Wheel for
> read/write and so on.
>
> Again, $heap->{listener} is only available if I use the Acceptor
> callback. $heap->{client} seems to be a ReadWrite wheel. I tried
> accessing the Handle for this wheel (which should be the socket),
> but I'm not getting anywhere.
>
> Thanks,
> Rohan
>
>
| |
| Rohan Almeida 2007-05-23, 4:38 am |
|
I need access to the socket, as I have to use the getsockopt
call. I don't have any problems with using SocketFactory and
Wheels for my server. Just though it would be nice if
PoCo::Server::TCP does provide access to the socket.
Thanks,
Rohan
Matt Sickler wrote:
> There arent any documented ways to get at a ReadWrite wheel's handle.
> The non-POE way you could do it (and breaking encapsulation) would be to
> use
> $heap->{client}->[ POE::Wheel::ReadWrite::HANDLE_INPUT ] and
> $heap->{client}->[ POE::Wheel::ReadWrite::HANDLE_OUTPUT ]
> ( those would be the same in many situations ).
> This breaks encapsulation and could change at no notice and its all your
> fault.
>
> A better question you need to ask is why do you need to get at the socket?
>
> On 5/22/07, Rohan Almeida <rohan@almeida.in> wrote:
>
| |
| Curtis J. Coleman 2007-05-23, 4:38 am |
| I had a need to retrieve TCP_MAXSEG from getsockopt once.
On Tue, May 22, 2007 at 09:51:04PM -0500, Matt Sickler wrote:[color=darkred]
> There arent any documented ways to get at a ReadWrite wheel's handle.
> The non-POE way you could do it (and breaking encapsulation) would be to use
> $heap->{client}->[ POE::Wheel::ReadWrite::HANDLE_INPUT ] and
> $heap->{client}->[ POE::Wheel::ReadWrite::HANDLE_OUTPUT ]
> ( those would be the same in many situations ).
> This breaks encapsulation and could change at no notice and its all your
> fault.
>
> A better question you need to ask is why do you need to get at the socket?
>
> On 5/22/07, Rohan Almeida <rohan@almeida.in> wrote:
| |
| Matt Sickler 2007-05-23, 7:22 pm |
| The component wouldnt be the one to provide access to it.
You would need to patch POE::Wheel::ReadWrite to provide an accessor
method to the input and output handles.
On 5/22/07, Rohan Almeida <rohan@almeida.in> wrote:
>
> I need access to the socket, as I have to use the getsockopt
> call. I don't have any problems with using SocketFactory and
> Wheels for my server. Just though it would be nice if
> PoCo::Server::TCP does provide access to the socket.
>
> Thanks,
> Rohan
>
> Matt Sickler wrote:
>
>
| |
| Nicholas Perez 2007-05-23, 7:22 pm |
| I seem to remember wanting similar functionality in the past and it
was countered for some reason. A wheel would be useless without the
handles (ie, yanked out via accessor), but it keeps the end developer
from holding onto a reference to the handles when building the wheel
in the first place.
On 5/23/07, Matt Sickler <crazyfordynamite@gmail.com> wrote:
> The component wouldnt be the one to provide access to it.
> You would need to patch POE::Wheel::ReadWrite to provide an accessor
> method to the input and output handles.
>
> On 5/22/07, Rohan Almeida <rohan@almeida.in> wrote:
>
| |
| Matt Sickler 2007-05-23, 7:22 pm |
| Perhaps a better way would be to have methods that do the getsockopt
calls themselves?
On 5/23/07, Nicholas Perez <nicholasrperez@gmail.com> wrote:
> I seem to remember wanting similar functionality in the past and it
> was countered for some reason. A wheel would be useless without the
> handles (ie, yanked out via accessor), but it keeps the end developer
> from holding onto a reference to the handles when building the wheel
> in the first place.
>
> On 5/23/07, Matt Sickler <crazyfordynamite@gmail.com> wrote:
>
| |
| Rohan Almeida 2007-05-23, 7:22 pm |
|
Matt Sickler wrote:
> Perhaps a better way would be to have methods that do the getsockopt
> calls themselves?
There would be no end to this. Why use layered methods when a
simple getsockopt (and others) on the socket would suffice?
--
Rohan
> On 5/23/07, Nicholas Perez <nicholasrperez@gmail.com> wrote:
>
| |
| Rohan Almeida 2007-05-23, 7:23 pm |
|
Matt Sickler wrote:
> Perhaps a better way would be to have methods that do the getsockopt
> calls themselves?
There would be no end to this. Why use layered methods when a
simple getsockopt (and others) on the socket would suffice?
--
Rohan
> On 5/23/07, Nicholas Perez <nicholasrperez@gmail.com> wrote:
>
| |
| Matt Sickler 2007-05-24, 4:35 am |
| I just committed a change that adds get_input_handle and
get_output_handle methods to Wheel::ReadWrite. :)
On 5/23/07, Rohan Almeida <rohan@almeida.in> wrote:
>
> Matt Sickler wrote:
>
> There would be no end to this. Why use layered methods when a
> simple getsockopt (and others) on the socket would suffice?
>
> --
> Rohan
>
>
>
>
| |
| Rohan Almeida 2007-05-24, 4:35 am |
|
Matt Sickler wrote:
> I just committed a change that adds get_input_handle and
> get_output_handle methods to Wheel::ReadWrite. :)
Thats great! I can see the changes in Sourceforge. Will download
the tarball from there.
Thanks,
Rohan
> On 5/23/07, Rohan Almeida <rohan@almeida.in> wrote:
>
| |
|
|
|
|
|
|
|
|
|
|