[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Comparing TCP sockets

Iñaki Baz Castillo

8/13/2008 9:08:00 PM

Hi, imagine I receive a TCP connection and I store the TCPSocket in a=20
variable "io_1":

io_1 =3D io

If I do "io_1.peeraddr" I can see the remote address.

If latter the connection is closed by the peer and I do "io_1.peeraddr" the=
n I=20
get an Exception because socket closed (ok).

Imagine later the *same* connection is received and I store it in "io_2".=20
Will "io_1 =3D=3D io_2" return true? or should I compare "peeraddr" Array f=
ields=20
one by one (address, port...)?

Thanks.

=2D-=20
I=C3=B1aki Baz Castillo

2 Answers

Eric Hodel

8/13/2008 11:46:00 PM

0

On Aug 13, 2008, at 14:08 PM, I=F1aki Baz Castillo wrote:

> Hi, imagine I receive a TCP connection and I store the TCPSocket in a
> variable "io_1":
>
> io_1 =3D io
>
> If I do "io_1.peeraddr" I can see the remote address.
>
> If latter the connection is closed by the peer and I do =20
> "io_1.peeraddr" then I
> get an Exception because socket closed (ok).
>
> Imagine later the *same* connection is received and I store it in =20
> "io_2".
> Will "io_1 =3D=3D io_2" return true?

No.

> or should I compare "peeraddr" Array fields one by one (address, =20
> port...)?

You can compare the Arrays without going field by field.=

Iñaki Baz Castillo

8/14/2008 12:20:00 AM

0

El Jueves, 14 de Agosto de 2008, Eric Hodel escribi=F3:
> On Aug 13, 2008, at 14:08 PM, I=F1aki Baz Castillo wrote:
> > Hi, imagine I receive a TCP connection and I store the TCPSocket in a
> > variable "io_1":
> >
> > io_1 =3D io
> >
> > If I do "io_1.peeraddr" I can see the remote address.
> >
> > If latter the connection is closed by the peer and I do
> > "io_1.peeraddr" then I
> > get an Exception because socket closed (ok).
> >
> > Imagine later the *same* connection is received and I store it in
> > "io_2".
> > Will "io_1 =3D=3D io_2" return true?
>
> No.

Thanks.



=2D-=20
I=F1aki Baz Castillo