TCP (or UDP) daytime client in Smalltalk

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

TCP (or UDP) daytime client in Smalltalk

stes

Hello,

I'm new to GNU Smalltalk but this package seems to compile (build) fine on Solaris 11.4 (Intel).

I think it compiled fine because 'gmake install' worked and I can enter some of the sample tutorial code snippets, and this works.

I've also created a Solaris IPS package for it (a binary package) so that it is easier to install.

# pkg list gst
NAME (PUBLISHER)                                  VERSION                    IFO
runtime/gst (nightly)                             3.2.91-11.4.24.0.0.71.0    i--

The above 'package' (pkg) is the package management system, so that the binary can be installed without configure+make install.

As a test, I would like to create a simple "TCP" or "UDP" daytime client in Smalltalk.

In Squeak (a different Smalltalk implementation) the following code works:

| r s addr |
addr := NetNameResolver addressFromString:'192.168.0.1'.
s := Socket newTCP connectTo:addr port:13.
r := s receiveData.
s close.
Transcript show:r.

When I try to evaluate the same code in gnu smalltalk:

$ gst
GNU Smalltalk ready

st> Smalltalk version
'GNU Smalltalk version 3.2.91'
st> | r s addr |
st> addr := NetNameResolver addressFromString:'192.168.0.1'.
Object: nil error: did not understand #addressFromString:
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #addressFromString: (SysExcept.st:1408)
UndefinedObject>>executeStatements (a String:1)
nil


Is there a way to load the NetNameResolver class in GNU smalltalk please ?

Or is there an example of TCP/IP (TCP or UDP) NetClient programming with gst ?

Thanks,
David Stes


Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

Derek Zhou-4
[hidden email] writes:
> Is there a way to load the NetNameResolver class in GNU smalltalk please ?
>
> Or is there an example of TCP/IP (TCP or UDP) NetClient programming with gst ?

gst ships with a sockets library; please check the included info
page. The documentation is scant; you may have to read the source
code. I suppose for simple client/server socket programming it should be
fairly easy.

Derek

Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

Johnksellers
Why am I getting these emails?

On Fri, May 29, 2020, 5:59 AM Derek Zhou <[hidden email]> wrote:

> [hidden email] writes:
> > Is there a way to load the NetNameResolver class in GNU smalltalk please
> ?
> >
> > Or is there an example of TCP/IP (TCP or UDP) NetClient programming with
> gst ?
>
> gst ships with a sockets library; please check the included info
> page. The documentation is scant; you may have to read the source
> code. I suppose for simple client/server socket programming it should be
> fairly easy.
>
> Derek
>
>

Seniorius Lurkius

Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

bill-auger
John -

my guess is that you are subscribed to the GNU smalltalk
mailing list

https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

Davide Grandi-3
... and if you look at the email's headers you'll see :

 > List-Id: Users mailing list for the GNU Smalltalk environment
<help-smalltalk.gnu.org>
 > List-Unsubscribe:
<https://lists.gnu.org/mailman/options/help-smalltalk>,
<mailto:[hidden email]?subject=unsubscribe>
 > List-Archive: <https://lists.gnu.org/archive/html/help-smalltalk>
 > List-Post: <mailto:[hidden email]>
 > List-Help: <mailto:[hidden email]?subject=help>
 > List-Subscribe:
<https://lists.gnu.org/mailman/listinfo/help-smalltalk>,
<mailto:[hidden email]?subject=subscribe>

.. the mailing list instructions to (un)subscribe, post, get help, see
the archives.

Bye,

     Davide

On 29/05/2020 22:12, bill-auger wrote:
> John -
>
> my guess is that you are subscribed to the GNU smalltalk
> mailing list
>
> https://lists.gnu.org/mailman/listinfo/help-smalltalk
>
--
Ing. Davide Grandi
email    : [hidden email]
linkedin : http://linkedin.com/in/davidegrandi


Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

stes
In reply to this post by stes

The docs have an incorrect reference:

https://www.gnu.org/software/smalltalk/manual/html_node/Network-support.html#Network-support

if you click on " Network programming with Sockets " that link is broken.

I've tried the following:

Eval [

PackageLoader fileInPackage: 'Sockets'.
PackageLoader fileInPackage: 'NetClients'.

s _ Socket remote:(SocketAddress createLoopbackHost) port:13.
(s upTo: Character cr) printNl.
s close.

]

This fails:

Object: nil error: did not understand #createLoopbackHost
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #createLoopbackHost (SysExcept.st:1408)
UndefinedObject>>executeStatements (daytime.st:7)


Apparently it does not know about the SocketAdress class (subclass of
IPAddress).  There must be some other way apparently to load that class.

Shouldn't loading the packages be sufficient to get the SocketAdress class ?

David

Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

Derek Zhou-4

[hidden email] writes:

> The docs have an incorrect reference:
>
> https://www.gnu.org/software/smalltalk/manual/html_node/Network-support.html#Network-support
>
> if you click on " Network programming with Sockets " that link is broken.
Use the locally install docs. And most likely you need to read the
source code as the doc is not that good.

>
> I've tried the following:
>
> Eval [
>
> PackageLoader fileInPackage: 'Sockets'.
> PackageLoader fileInPackage: 'NetClients'.
>
> s _ Socket remote:(SocketAddress createLoopbackHost) port:13.
> (s upTo: Character cr) printNl.
> s close.
>
> ]
>
> This fails:
>
> Object: nil error: did not understand #createLoopbackHost
> MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
> UndefinedObject(Object)>>doesNotUnderstand: #createLoopbackHost (SysExcept.st:1408)
> UndefinedObject>>executeStatements (daytime.st:7)
>
>
> Apparently it does not know about the SocketAdress class (subclass of
> IPAddress).  There must be some other way apparently to load that class.
>
> Shouldn't loading the packages be sufficient to get the SocketAdress class ?

Yes. However, gnu smalltalk has namespace. It should be Sockets.SocketAddress, or you
can <import: Sockets>

Derek

Reply | Threaded
Open this post in threaded view
|

Re: TCP (or UDP) daytime client in Smalltalk

stes

It works !  Thanks for your help:

Assuming that the old 'legacy' daytime stream server runs on tcp port 13:

$ gst daytime.st
Loading package ObjectDumper
Loading package Sockets
'Sat Jun  6 10:30:16 2020'

$ cat daytime.st

Eval [

PackageLoader fileInPackage: 'Sockets'.

s _ Sockets.Socket remote:(Sockets.SocketAddress createLoopbackHost) port:13.
(s upTo: Character cr) printNl.
s close.

]



So the problem was that you have to use the 'namespace'.

Thanks,
David Stes


----- Op 4 jun 2020 om 20:15 schreef Derek Zhou [hidden email]:

> [hidden email] writes:
>
>> The docs have an incorrect reference:
>>
>> https://www.gnu.org/software/smalltalk/manual/html_node/Network-support.html#Network-support
>>
>> if you click on " Network programming with Sockets " that link is broken.
> Use the locally install docs. And most likely you need to read the
> source code as the doc is not that good.
>>
>> I've tried the following:
>>
>> Eval [
>>
>> PackageLoader fileInPackage: 'Sockets'.
>> PackageLoader fileInPackage: 'NetClients'.
>>
>> s _ Socket remote:(SocketAddress createLoopbackHost) port:13.
>> (s upTo: Character cr) printNl.
>> s close.
>>
>> ]
>>
>> This fails:
>>
>> Object: nil error: did not understand #createLoopbackHost
>> MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
>> UndefinedObject(Object)>>doesNotUnderstand: #createLoopbackHost
>> (SysExcept.st:1408)
>> UndefinedObject>>executeStatements (daytime.st:7)
>>
>>
>> Apparently it does not know about the SocketAdress class (subclass of
>> IPAddress).  There must be some other way apparently to load that class.
>>
>> Shouldn't loading the packages be sufficient to get the SocketAdress class ?
>
> Yes. However, gnu smalltalk has namespace. It should be Sockets.SocketAddress,
> or you
> can <import: Sockets>
>
> Derek