[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help on sending a UDP Packet
From: |
address@hidden |
Subject: |
Re: Help on sending a UDP Packet |
Date: |
Sun, 10 Jan 2021 20:35:28 +0100 (CET) |
I think some Smalltalk systems (Cuis and possibly others) display _ as the
left-arrow.
In "Cuis" http://cuis-smalltalk.org/ this looks like the examples in the Blue
Book.
I think the original XEROX Smalltalk systems used those characters, but I've
never used them,
but in Cuis the _ prints as left-arrow, very nice.
See https://www.gnu.org/software/smalltalk/manual/html_node/Syntax.html
for a discussion of := and _ in GNU smalltalk.
The Blue Book "Smalltalk-80 language and implementation" writes on page 44
"An assignment prefix is composed of the name of the variable whose
value will be changed followed by a left arrow ()"
The character that is displayed there is the left arrow.
I think perhaps the XEROX Smalltalk also used a up-arrow to return values where
GNU smalltalk uses the caret ^.
This begs the question (I don't know the answer) whether with Unicode
characters,
GNU smalltalk and fonts for a Linux/Unix terminal could be made to print
up-arrow and left-arrow,
for GNU smalltalk ...
Is there a way to do this ? There are fonts that have those characters, so
perhaps somebody managed to do this.
Regarding other issues:
when I wrote 1) this was a quick assignment that was sufficient for me,
because I send and receive UDP packets (datagrams) on the localhost
in your case you'll have to check the classes for appropriate messages but I
think they provide a method to create an address object from a dot decimal
syntax ipv4 address
2) perhaps this is wrong or unnecessary the idea was to create an Array
instance
#(1 2 3) would have been better perhaps than #'hello world'
anyway for DNS or UDP requests where the Datagram that is sent, does matter, it
would be necessary to investigate,
but in my case for the UDP daytime service, it just receives a UDP packet and
sends back the daytime in a UDP response,
so the UDP packet that is sent, does not matter
4/3) no I think statement 2) does that : DatagramSocket new
5) the nextPut:datagram puts the datagram (send) and yes, the daytime service
will respond to it
6) I think it blocks yes. I can test this by removing the nextPut: so that no
responds is sent,
and the statements block, because no UDP packet comes in
If I control-c then I get the following trace which seems to show the
Delay>wait in the Socket
waitUntil:then:onTimeoutDo: where perhaps the issue of "onTimeoutDo:" block
can be seen
^CObject: nil error: interrupted!!!
SystemExceptions.UserInterrupt(Exception)>>signal (ExcHandling.st:254)
SystemExceptions.UserInterrupt class(Exception class)>>signal
(ExcHandling.st:151)
UndefinedObject(Object)>>userInterrupt (Object.st:1414)
optimized [] in Delay>>wait (Delay.st:285)
BlockClosure>>ensure: (BlkClosure.st:268)
Delay>>wait (Delay.st:279)
Sockets.DatagramSocket(Sockets.AbstractSocket)>>waitUntil:then:onTimeoutDo:
(Sockets.star#VFS.ZipFile/Sockets.st:522)
Sockets.DatagramSocket>>receive: (Sockets.star#VFS.ZipFile/Sockets.st:756)
UndefinedObject>>executeStatements (daytime-dgram.st:7)
Object: nil error: did not understand #asString
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254
Anyway there is a UNIX / Linux utility "netcat" (or nc) which acts very similar:
$ nc localhost 13
Sun Jan 10 20:32:07 2021
$ nc -u localhost 13
123
Sun Jan 10 20:32:16 2021
^C
when using "nc" (netcat) in udp mode -u I have to send something to the service
to get a reply.
----- Op 10 jan 2021 om 19:49 schreef Gary Highberger gary.highberger@gmail.com:
> Hello David and all,
>
> I have a few (noob) questions about the UDP example Smalltalk program. More
> questions likely to follow as I come up to speed. Your patience is much
> appreciated David and everybody.
>
> QUESTIONS:
> • Is "_" the preferred assignment operator? I've been seeing ":=" too. I
> don't have a back arrow on my keyboard. I guess the PARC people used "_".
>
> • Does statement 1)
> assign the destination IP address? Note that for my application, the source
> and destination addresses will be different.
>
> • Does statement 3)
> populate the (UDP) datagram socket with the message, port, and address? Why
> a "#" symbol prefixing the message string, 'hello world'?
>
> • Does statement 4)
> create a listening socket?
>
> • Does statement 5)
> trigger the send?
>
> • Does statement 6)
> block until the UDP response?
>
> +---------------------------------------------------------+
>
> UDP Smalltalk (example) program:
>
> 1) h _ Sockets.SocketAddress createLoopbackHost.
>
> 2) s _ Sockets.DatagramSocket new.
>
> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
>
> 4) answer _ Sockets.Datagram new.
>
> 5) s nextPut:d.
>
> 6) s receive:answer.
>
> 7) (answer data) asString printNl.
>
> 8) s close.
>
> Gary Highberger
>
>
> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <gary.highberger@gmail.com>
> wrote:
>
>> Good morning David,
>>
>> I'm not familiar with 'daytime' but will come up to speed on it and get it
>> and your use cases running and report my findings for everybody to see.
>>
>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
>> very short and simple.
>>
>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>>
>> I used my cell phone as the destination, my home WiFi as the network, and
>> tcpdump to see the packet.
>>
>> Thank you David for the Smalltalk code fragments and introducing me to
>> inetd and 'daytime'.
>>
>> Gary Highberger
>>
>>
- Help on sending a UDP Packet, Gary Highberger, 2021/01/06
- Re: Help on sending a UDP Packet, address@hidden, 2021/01/07
- Re: Help on sending a UDP Packet, Gary Highberger, 2021/01/10
- Re: Help on sending a UDP Packet, Gary Highberger, 2021/01/10
- Re: Help on sending a UDP Packet,
address@hidden <=
- display _ as left arrow (was Re: Help on sending a UDP Packet), address@hidden, 2021/01/10
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), address@hidden, 2021/01/10
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), address@hidden, 2021/01/10
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), Derek Zhou, 2021/01/11
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), address@hidden, 2021/01/11
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), Derek Zhou, 2021/01/12
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), address@hidden, 2021/01/12
- Re: display _ as left arrow (was Re: Help on sending a UDP Packet), Derek Zhou, 2021/01/12
- Re: Help on sending a UDP Packet, Gary Highberger, 2021/01/12
- Re: Help on sending a UDP Packet, address@hidden, 2021/01/12