Pharo and network

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Pharo and network

Adrien BARREAU
Hello,

I read these documents:
http://book.pharo-project.org/book/networking/Socket
http://wiki.squeak.org/squeak/325

but I still don't get what I want with pharo.

Here is the idea: I want a socket to listen a port while pharo is launched as a deamon.

I tried to test the sockets with this idea:
- creation of two sockets in two workspaces
- server:

| server st |
st := String new.
server := Socket newTCP.
server listenOn: 12345 backlogSize: 4.
server receiveDataInto: st

- client:

| s |
s connectTo: ('127.0.0.1' asByteArray asSocketAddress) port: 12345.
s sendData: 'Hello'

- the connectTo:port: fails, and I don't understand why

So I have no idea ...

Adrien.
Reply | Threaded
Open this post in threaded view
|

Re: Pharo and network

Guillermo Polito
comments inline

On Fri, Jan 14, 2011 at 7:05 PM, Adrien BARREAU <[hidden email]> wrote:
Hello,

I read these documents:
http://book.pharo-project.org/book/networking/Socket
http://wiki.squeak.org/squeak/325

but I still don't get what I want with pharo.

Here is the idea: I want a socket to listen a port while pharo is launched as a deamon.

I tried to test the sockets with this idea:
- creation of two sockets in two workspaces
- server:

| server st |
st := String new.
server := Socket newTCP.
server listenOn: 12345 backlogSize: 4.
server receiveDataInto: st

- client:

| s |
s connectTo: ('127.0.0.1' asByteArray asSocketAddress) port: 12345.

Shouldn't this lead to a MNU? I don't know how to initialize a socket, but maybe you forget to instantiate the socket, or you have to talk to the class.
 
s sendData: 'Hello'

- the connectTo:port: fails, and I don't understand why

So I have no idea ...

Adrien.

Cheers,

Reply | Threaded
Open this post in threaded view
|

Re: Pharo and network

Adrien BARREAU



Date: Fri, 14 Jan 2011 19:13:14 -0300
From: [hidden email]
To: [hidden email]
Subject: Re: [Pharo-users] Pharo and network

comments inline

On Fri, Jan 14, 2011 at 7:05 PM, Adrien BARREAU <[hidden email]> wrote:
Hello,

I read these documents:
http://book.pharo-project.org/book/networking/Socket
http://wiki.squeak.org/squeak/325

but I still don't get what I want with pharo.

Here is the idea: I want a socket to listen a port while pharo is launched as a deamon.

I tried to test the sockets with this idea:
- creation of two sockets in two workspaces
- server:

| server st |
st := String new.
server := Socket newTCP.
server listenOn: 12345 backlogSize: 4.
server receiveDataInto: st

- client:

| s |
s connectTo: ('127.0.0.1' asByteArray asSocketAddress) port: 12345.

Shouldn't this lead to a MNU? I don't know how to initialize a socket, but maybe you forget to instantiate the socket, or you have to talk to the class.

I forgot the instantiation when I copied for this mail, it is instantiate
My server works if I connect with a telnet terminal
 
s sendData: 'Hello'

- the connectTo:port: fails, and I don't understand why

So I have no idea ...

Adrien.

Cheers,

Reply | Threaded
Open this post in threaded view
|

Re: Pharo and network

Olivier Auverlot
In reply to this post by Adrien BARREAU
Hi Adrien,

Could you try :

| s |
s := Socket new.
s connectTo: (NetNameResolver addressForName: 'localhost') port: 12345.

Best regards
Olivier ;-)
www.auverlot.fr
Hello,

I read these documents:
http://book.pharo-project.org/book/networking/Socket
http://wiki.squeak.org/squeak/325

but I still don't get what I want with pharo.

Here is the idea: I want a socket to listen a port while pharo is launched as a deamon.

I tried to test the sockets with this idea:
- creation of two sockets in two workspaces
- server:

| server st |
st := String new.
server := Socket newTCP.
server listenOn: 12345 backlogSize: 4.
server receiveDataInto: st

- client:

| s |
s connectTo: ('127.0.0.1' asByteArray asSocketAddress) port: 12345.
s sendData: 'Hello'

- the connectTo:port: fails, and I don't understand why

So I have no idea ...

Adrien.

Reply | Threaded
Open this post in threaded view
|

Re: Pharo and network

Michael Roberts-2
yes... depending on your OS and version of Pharo, 127.0.0.1 does not
always work as the destination from your client to your server socket.
Did Olivier's code snippet work?  try using netcat or lsof (unix) to
see and interact with the state of your sockets.

There is also a SocketStream implementation (somewhere) that hides a
lot of this.

cheers,
Mike

On Fri, Jan 14, 2011 at 11:35 PM, Olivier Auverlot
<[hidden email]> wrote:

> Hi Adrien,
>
> Could you try :
>
> | s |
> s := Socket new.
> s connectTo: (NetNameResolver addressForName: 'localhost') port: 12345.
>
> Best regards
> Olivier ;-)
> www.auverlot.fr
>
> Hello,
>
> I read these documents:
> http://book.pharo-project.org/book/networking/Socket
> http://wiki.squeak.org/squeak/325
>
> but I still don't get what I want with pharo.
>
> Here is the idea: I want a socket to listen a port while pharo is launched
> as a deamon.
>
> I tried to test the sockets with this idea:
> - creation of two sockets in two workspaces
> - server:
>
> | server st |
> st := String new.
> server := Socket newTCP.
> server listenOn: 12345 backlogSize: 4.
> server receiveDataInto: st
>
> - client:
>
> | s |
> s connectTo: ('127.0.0.1' asByteArray asSocketAddress) port: 12345.
> s sendData: 'Hello'
>
> - the connectTo:port: fails, and I don't understand why
>
> So I have no idea ...
>
> Adrien.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Pharo and network

Adrien BARREAU
Hi,

This was sent to me on the pharo-project mailing list, it answers my question.
Thanks for your answers ;)

Adrien.

> Date: Mon, 17 Jan 2011 23:41:09 +0000
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Pharo-users] Pharo and network
>
> yes... depending on your OS and version of Pharo, 127.0.0.1 does not
> always work as the destination from your client to your server socket.
> Did Olivier's code snippet work? try using netcat or lsof (unix) to
> see and interact with the state of your sockets.
>
> There is also a SocketStream implementation (somewhere) that hides a
> lot of this.
>
> cheers,
> Mike
>
> On Fri, Jan 14, 2011 at 11:35 PM, Olivier Auverlot
> <[hidden email]> wrote:
> > Hi Adrien,
> >
> > Could you try :
> >
> > | s |
> > s := Socket new.
> > s connectTo: (NetNameResolver addressForName: 'localhost') port: 12345.
> >
> > Best regards
> > Olivier ;-)
> > www.auverlot.fr
> >
> > Hello,
> >
> > I read these documents:
> > http://book.pharo-project.org/book/networking/Socket
> > http://wiki.squeak.org/squeak/325
> >
> > but I still don't get what I want with pharo.
> >
> > Here is the idea: I want a socket to listen a port while pharo is launched
> > as a deamon.
> >
> > I tried to test the sockets with this idea:
> > - creation of two sockets in two workspaces
> > - server:
> >
> > | server st |
> > st := String new.
> > server := Socket newTCP.
> > server listenOn: 12345 backlogSize: 4.
> > server receiveDataInto: st
> >
> > - client:
> >
> > | s |
> > s connectTo: ('127.0.0.1' asByteArray asSocketAddress) port: 12345.
> > s sendData: 'Hello'
> >
> > - the connectTo:port: fails, and I don't understand why
> >
> > So I have no idea ...
> >
> > Adrien.
> >
> >
>