Pharo-users
By thread
pharo-users@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
October 2014
- 81 participants
- 560 messages
Re: [Pharo-users] UDP example
by Annick Fron
I think the following code does polling :
>> [ result := socket receiveUDPDataInto: buffer.
>> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
and it is preferable to use semaphores, which are more efficient.
Is it possible to replace it by :
socket waitForData.
result :- socket receiveUDPDataInto: buffer ???
Annick
PS : I have successfully used broadcast UDP on Raspberry
Le 21 oct. 2014 à 16:08, Henrik Johansen <henrik.s.johansen(a)veloxit.no> a écrit :
>
>> On 21 Oct 2014, at 3:52 , Luc Fabresse <luc.fabresse(a)gmail.com> wrote:
>>
>>
>>
>> 2014-10-21 15:40 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
>>
>> > On 21 Oct 2014, at 15:29, Luc Fabresse <luc.fabresse(a)gmail.com> wrote:
>> >
>> >
>> > yes examples are good.
>> > but I also suggest to use a stream on a UDPSocket instead of manipulating the socket directly in the model code.
>> > Usually, it lowers the code complexity.
>>
>> Hmm, are you sure that is even possible with UDP sockets ?
>>
>> I was thinking of using a stream on the data part of the datagram packets.
>> If you have structured data it simpler to use #next or #nextImage, ...
>>
>> And if the data part is bigger than one datagram packet (65535 IIRC), you can append to the stream as soon as you receive the next packet.
>>
>> Does it sounds good?
>>
>> Cheers,
>>
>> Luc
>
> UDP delivery isn't ordered, nor reliable.
> Build those into a Stream wrapper in order to reliably reconstruct a data stream from the sender, and you're almost back to TCP...
>
> Cheers,
> Henry
Oct. 21, 2014
Re: [Pharo-users] ConfigurationOfSandstoneDb
by stepharo
you should copy it into the metarepo :)
On 21/10/14 13:18, mikefilonov wrote:
> Hello,
>
> I have fixed SandstoneDb to work with Pharo3.0 (4.0 works as well) and also
> submitted a ConfigurationOfSandstoneDb so you may use the repository owned
> by Ramon Leon to fetch the sources:
>
> http://smalltalkhub.com/#!/~gnaritas/SandstoneDb
>
> It would be perfect if someone could take some time to look over the
> configuration.
>
> Thank you
>
>
>
> --
> View this message in context: http://forum.world.st/ConfigurationOfSandstoneDb-tp4785703.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>
Oct. 21, 2014
Re: [Pharo-users] new Pharo Success story
by stepharo
> Not right now, but if I could, how can I collaborate with that?
Excellent.
Ask esteban because this should be added to marina.
>
> So instead of one Esteban, you can have two :)
this is cool
> Esteban A. Maringolo
>
>
> 2014-10-21 3:48 GMT-03:00 stepharo <stepharo(a)free.fr>:
>> I agree but I prefer that esteban works on spur.
>>
>> Stef
>>
>>
>> On 20/10/14 17:43, Esteban A. Maringolo wrote:
>>> 2014-10-20 6:41 GMT-03:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
>>>
>>>> It is a lot of work to do a project inside such a big bank, let alone
>>>> make a success of it.
>>>> Congratulation to Tomas and the rest of his team.
>>> +1
>>>
>>> suggestion: can the success page be splitted into different pages?
>>> I prefer a main success page with the logos and/or excerpts of the
>>> solutions linking to the full success page case.
>>>
>>> Regards!
>>>
>>>
>>> Esteban A. Maringolo
>>>
>>>
>>
>
Oct. 21, 2014
Re: [Pharo-users] UDP example
by Henrik Johansen
> On 21 Oct 2014, at 3:52 , Luc Fabresse <luc.fabresse(a)gmail.com> wrote:
>
>
>
> 2014-10-21 15:40 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu <mailto:sven@stfx.eu>>:
>
> > On 21 Oct 2014, at 15:29, Luc Fabresse <luc.fabresse(a)gmail.com <mailto:luc.fabresse@gmail.com>> wrote:
> >
> >
> > yes examples are good.
> > but I also suggest to use a stream on a UDPSocket instead of manipulating the socket directly in the model code.
> > Usually, it lowers the code complexity.
>
> Hmm, are you sure that is even possible with UDP sockets ?
>
> I was thinking of using a stream on the data part of the datagram packets.
> If you have structured data it simpler to use #next or #nextImage, ...
>
> And if the data part is bigger than one datagram packet (65535 IIRC), you can append to the stream as soon as you receive the next packet.
>
> Does it sounds good?
>
> Cheers,
>
> Luc
UDP delivery isn't ordered, nor reliable.
Build those into a Stream wrapper in order to reliably reconstruct a data stream from the sender, and you're almost back to TCP...
Cheers,
Henry
Oct. 21, 2014
Re: [Pharo-users] UDP example
by Luc Fabresse
2014-10-21 15:40 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
>
> > On 21 Oct 2014, at 15:29, Luc Fabresse <luc.fabresse(a)gmail.com> wrote:
> >
> >
> > yes examples are good.
> > but I also suggest to use a stream on a UDPSocket instead of
> manipulating the socket directly in the model code.
> > Usually, it lowers the code complexity.
>
> Hmm, are you sure that is even possible with UDP sockets ?
>
I was thinking of using a stream on the data part of the datagram packets.
If you have structured data it simpler to use #next or #nextImage, ...
And if the data part is bigger than one datagram packet (65535 IIRC), you
can append to the stream as soon as you receive the next packet.
Does it sounds good?
Cheers,
Luc
>
> I have never seen that ...
>
> > Luc
> >
> > 2014-10-21 10:36 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> > OK good.
> >
> > I think it would be best to add some examples to the image:
> >
> >
> https://pharo.fogbugz.com/f/cases/14275/Add-some-decent-TCP-UDP-examples-an…
> >
> > I will do that in the coming days.
> >
> > > On 21 Oct 2014, at 10:20, Annick Fron <list(a)afceurope.com> wrote:
> > >
> > > OK super, this example works. I got confused because I did not
> understand that you had 2 variables, buffer passed as argument and result
> as return.
> > >
> > > Annick
> > > Le 21 oct. 2014 à 09:53, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit
> :
> > >
> > >> The buffer that you supply to #receiveUDPDataInto: is either a String
> or a ByteArray, preallocated to a certain size. It gets filled with the
> incoming data part of the datagram. It should be large enough, it never
> overflows, if it is too small, you simply miss data (it is lost). If you
> preallocate N bytes, the result, the incoming data, might be less.
> > >>
> > >> The result from #receiveUDPDataInto: is a 4 element array, that I
> described before. The fields you are looking for are in the second (the ip
> address of the sender, a 4 element byte array) and in third (the port of
> the sender) slot. The first element is the actual number of bytes read. You
> need to copy from 1 to that size out of the buffer.
> > >>
> > >> The other fields that are in a datagram, outside the user data, are
> not accessible. You don't need them, unless you are implementing a TCP/IP
> stack yourself.
> > >>
> > >> Did you try this example ?
> > >>
> > >> "An UDP echo server on port 6666"
> > >> [ Socket newUDP in: [ :socket |
> > >> | loop buffer result input |
> > >> buffer := String new: 256.
> > >> loop := true.
> > >> socket setPort: 6666.
> > >> [ loop ] whileTrue: [
> > >> [ result := socket receiveUDPDataInto: buffer.
> > >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait
> ].
> > >> input := buffer copyFrom: 1 to: result first.
> > >> socket sendUDPData: input toHost: result second port: result third.
> > >> (input beginsWith: #quit) ifTrue: [ loop := false ] ].
> > >> socket closeAndDestroy ] ] forkAt: Processor userBackgroundPriority
> named: 'UDP echo server'.
> > >>
> > >> "Any message sent gets echoed back"
> > >> Socket newUDP in: [ :socket |
> > >> | buffer result |
> > >> socket sendUDPData: 'testing ', 99 atRandom asString toHost:
> NetNameResolver localHostAddress port: 6666.
> > >> buffer := String new: 256.
> > >> [ result := socket receiveUDPDataInto: buffer.
> > >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> > >> socket closeAndDestroy.
> > >> { result. buffer. buffer copyFrom: 1 to: result first } ].
> > >>
> > >> "Send quit to stop the server"
> > >> Socket newUDP in: [ :socket |
> > >> | buffer result |
> > >> socket sendUDPData: 'quit' toHost: NetNameResolver localHostAddress
> port: 6666.
> > >> buffer := String new: 256.
> > >> [ result := socket receiveUDPDataInto: buffer.
> > >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> > >> socket closeAndDestroy.
> > >> { result. buffer. buffer copyFrom: 1 to: result first } ].
> > >>
> > >> In a terminal (OSX or Linux), you can send a message like this:
> > >>
> > >> $ nc -u 127.0.0.1 6666
> > >> foo bar
> > >> foo bar
> > >> quit
> > >> quit
> > >>
> > >>> On 21 Oct 2014, at 09:31, Annick Fron <list(a)afceurope.com> wrote:
> > >>>
> > >>> Sven,
> > >>>
> > >>> I have put a halt in your sync method, but receiveUDPData comes with
> 64 bytes in your app, whereas you have provisioned 48 bytes.
> > >>> So since you start data at 33, I guess what you receive is the usual
> datagram IP header on 16 bytes, then the UDP header on 16 bytes.
> > >>>
> http://fr.wikipedia.org/wiki/Internet_Protocol#mediaviewer/File:Ipv4_header…
> > >>> http://fr.wikipedia.org/wiki/User_Datagram_Protocol
> > >>>
> > >>> If this is correct, I should see the source IP address on 4 bytes
> starting at byte 9, and the total length should be on 4 bytes starting at
> byte 5, and not at byte 1.
> > >>>
> > >>> Annick
> > >>>
> > >>> Le 20 oct. 2014 Ã 17:29, Sven Van Caekenberghe <sven(a)stfx.eu> a
> écrit :
> > >>>
> > >>>> Annick,
> > >>>>
> > >>>>> On 20 Oct 2014, at 17:12, Annick Fron <list(a)afceurope.com> wrote:
> > >>>>>
> > >>>>> Thank you but your explanation does not explain what is the type
> (signed unsigned) and the size of each header component.
> > >>>>> Thus it is impossible to work with that.
> > >>>>
> > >>>> I think you are making this way more difficult than it is.
> > >>>>
> > >>>> ZTimestampSNTPClient>>#sync contains a simple, runnable example of
> using datagrams (with a busy wait blocking the calling thread, which is
> only good for something simple, because normally datagrams are
> asynchronous, but that is another story).
> > >>>>
> > >>>> What you get back from #receiveUDPDataInto: is an Array with 4
> elements:
> > >>>>
> > >>>> - number of bytes received, Integer
> > >>>> - address of sender, ByteArray (use NetNameResolver if necessary)
> > >>>> - port of sender, Integer
> > >>>> - whether more datagrams are available for reading, Boolean
> > >>>>
> > >>>> The data is in the reallocated buffer that you supplied,
> aStringOrByteArray.
> > >>>>
> > >>>> This is all perfectly useable at the Pharo level.
> > >>>>
> > >>>> The question about signed/unsigned sounds like a C question, for
> which this is the wrong list, no ? I am sure it is quite easy to find C
> code that works with datagrams on your platform. A byte array is an
> unsigned char array as far as I remember ...
> > >>>>
> > >>>> What you put inside the datagram, is up to you and your application.
> > >>>>
> > >>>> HTH,
> > >>>>
> > >>>> Sven
> > >>>>
> > >>>>> Annick
> > >>>>>
> > >>>>> Le 17 oct. 2014 Ã 19:09, Sven Van Caekenberghe <sven(a)stfx.eu> a
> écrit :
> > >>>>>
> > >>>>>> Yes, you have to use the methods in the protocol 'datagrams' of
> Socket.
> > >>>>>>
> > >>>>>> When you receive a datagram, the IP:PORT of the other party is
> included, see #receiveUDPDataInto:'c comment.
> > >>>>>>
> > >>>>>> It is all a bit low level, but it works well.
> > >>>>>>
> > >>>>>> On 17 Oct 2014, at 18:15, Annick Fron <list(a)afceurope.com> wrote:
> > >>>>>>
> > >>>>>>> Thank you, but I am confused.
> > >>>>>>> I have checked your NTP code, and it uses
> > >>>>>>> sendUDPData and not sendData. Same for receiveUDPData.
> > >>>>>>> Besides how is it possible to know where the message comes from
> in a broadcast mode ??
> > >>>>>>> Annick
> > >>>>>>> Le 17 oct. 2014 Ã 17:35, Sven Van Caekenberghe <sven(a)stfx.eu> a
> écrit :
> > >>>>>>>
> > >>>>>>>> UDP is pretty easy, just send and receive byte arrays
> basically, mostly non-blocking.
> > >>>>>>>>
> > >>>>>>>> http://forum.world.st/UDP-Listener-example-td4362851.html
> > >>>>>>>> http://forum.world.st/SysLogSender-UDP-td4745862.html
> > >>>>>>>>
> > >>>>>>>> The API is all in Socket.
> > >>>>>>>>
> > >>>>>>>> On 17 Oct 2014, at 17:09, Annick Fron <list(a)afceurope.com>
> wrote:
> > >>>>>>>>
> > >>>>>>>>> Hi,
> > >>>>>>>>>
> > >>>>>>>>> I was not able to find a UDP example in pharo.
> > >>>>>>>>>
> > >>>>>>>>> There are only TCP examples.
> > >>>>>>>>>
> > >>>>>>>>> Any pointer ?
> > >>>>>>>>>
> > >>>>>>>>> Annick
> > >>>>>>>>>
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>
> > >>>>>>
> > >>>>>
> > >>>>
> > >>>
> > >>
> > >
> >
> >
> >
>
>
>
Oct. 21, 2014
Re: [Pharo-users] UDP example
by Sven Van Caekenberghe
> On 21 Oct 2014, at 15:29, Luc Fabresse <luc.fabresse(a)gmail.com> wrote:
>
>
> yes examples are good.
> but I also suggest to use a stream on a UDPSocket instead of manipulating the socket directly in the model code.
> Usually, it lowers the code complexity.
Hmm, are you sure that is even possible with UDP sockets ?
I have never seen that ...
> Luc
>
> 2014-10-21 10:36 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> OK good.
>
> I think it would be best to add some examples to the image:
>
> https://pharo.fogbugz.com/f/cases/14275/Add-some-decent-TCP-UDP-examples-an…
>
> I will do that in the coming days.
>
> > On 21 Oct 2014, at 10:20, Annick Fron <list(a)afceurope.com> wrote:
> >
> > OK super, this example works. I got confused because I did not understand that you had 2 variables, buffer passed as argument and result as return.
> >
> > Annick
> > Le 21 oct. 2014 à 09:53, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit :
> >
> >> The buffer that you supply to #receiveUDPDataInto: is either a String or a ByteArray, preallocated to a certain size. It gets filled with the incoming data part of the datagram. It should be large enough, it never overflows, if it is too small, you simply miss data (it is lost). If you preallocate N bytes, the result, the incoming data, might be less.
> >>
> >> The result from #receiveUDPDataInto: is a 4 element array, that I described before. The fields you are looking for are in the second (the ip address of the sender, a 4 element byte array) and in third (the port of the sender) slot. The first element is the actual number of bytes read. You need to copy from 1 to that size out of the buffer.
> >>
> >> The other fields that are in a datagram, outside the user data, are not accessible. You don't need them, unless you are implementing a TCP/IP stack yourself.
> >>
> >> Did you try this example ?
> >>
> >> "An UDP echo server on port 6666"
> >> [ Socket newUDP in: [ :socket |
> >> | loop buffer result input |
> >> buffer := String new: 256.
> >> loop := true.
> >> socket setPort: 6666.
> >> [ loop ] whileTrue: [
> >> [ result := socket receiveUDPDataInto: buffer.
> >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> >> input := buffer copyFrom: 1 to: result first.
> >> socket sendUDPData: input toHost: result second port: result third.
> >> (input beginsWith: #quit) ifTrue: [ loop := false ] ].
> >> socket closeAndDestroy ] ] forkAt: Processor userBackgroundPriority named: 'UDP echo server'.
> >>
> >> "Any message sent gets echoed back"
> >> Socket newUDP in: [ :socket |
> >> | buffer result |
> >> socket sendUDPData: 'testing ', 99 atRandom asString toHost: NetNameResolver localHostAddress port: 6666.
> >> buffer := String new: 256.
> >> [ result := socket receiveUDPDataInto: buffer.
> >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> >> socket closeAndDestroy.
> >> { result. buffer. buffer copyFrom: 1 to: result first } ].
> >>
> >> "Send quit to stop the server"
> >> Socket newUDP in: [ :socket |
> >> | buffer result |
> >> socket sendUDPData: 'quit' toHost: NetNameResolver localHostAddress port: 6666.
> >> buffer := String new: 256.
> >> [ result := socket receiveUDPDataInto: buffer.
> >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> >> socket closeAndDestroy.
> >> { result. buffer. buffer copyFrom: 1 to: result first } ].
> >>
> >> In a terminal (OSX or Linux), you can send a message like this:
> >>
> >> $ nc -u 127.0.0.1 6666
> >> foo bar
> >> foo bar
> >> quit
> >> quit
> >>
> >>> On 21 Oct 2014, at 09:31, Annick Fron <list(a)afceurope.com> wrote:
> >>>
> >>> Sven,
> >>>
> >>> I have put a halt in your sync method, but receiveUDPData comes with 64 bytes in your app, whereas you have provisioned 48 bytes.
> >>> So since you start data at 33, I guess what you receive is the usual datagram IP header on 16 bytes, then the UDP header on 16 bytes.
> >>> http://fr.wikipedia.org/wiki/Internet_Protocol#mediaviewer/File:Ipv4_header…
> >>> http://fr.wikipedia.org/wiki/User_Datagram_Protocol
> >>>
> >>> If this is correct, I should see the source IP address on 4 bytes starting at byte 9, and the total length should be on 4 bytes starting at byte 5, and not at byte 1.
> >>>
> >>> Annick
> >>>
> >>> Le 20 oct. 2014 à 17:29, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit :
> >>>
> >>>> Annick,
> >>>>
> >>>>> On 20 Oct 2014, at 17:12, Annick Fron <list(a)afceurope.com> wrote:
> >>>>>
> >>>>> Thank you but your explanation does not explain what is the type (signed unsigned) and the size of each header component.
> >>>>> Thus it is impossible to work with that.
> >>>>
> >>>> I think you are making this way more difficult than it is.
> >>>>
> >>>> ZTimestampSNTPClient>>#sync contains a simple, runnable example of using datagrams (with a busy wait blocking the calling thread, which is only good for something simple, because normally datagrams are asynchronous, but that is another story).
> >>>>
> >>>> What you get back from #receiveUDPDataInto: is an Array with 4 elements:
> >>>>
> >>>> - number of bytes received, Integer
> >>>> - address of sender, ByteArray (use NetNameResolver if necessary)
> >>>> - port of sender, Integer
> >>>> - whether more datagrams are available for reading, Boolean
> >>>>
> >>>> The data is in the reallocated buffer that you supplied, aStringOrByteArray.
> >>>>
> >>>> This is all perfectly useable at the Pharo level.
> >>>>
> >>>> The question about signed/unsigned sounds like a C question, for which this is the wrong list, no ? I am sure it is quite easy to find C code that works with datagrams on your platform. A byte array is an unsigned char array as far as I remember ...
> >>>>
> >>>> What you put inside the datagram, is up to you and your application.
> >>>>
> >>>> HTH,
> >>>>
> >>>> Sven
> >>>>
> >>>>> Annick
> >>>>>
> >>>>> Le 17 oct. 2014 à 19:09, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit :
> >>>>>
> >>>>>> Yes, you have to use the methods in the protocol 'datagrams' of Socket.
> >>>>>>
> >>>>>> When you receive a datagram, the IP:PORT of the other party is included, see #receiveUDPDataInto:'c comment.
> >>>>>>
> >>>>>> It is all a bit low level, but it works well.
> >>>>>>
> >>>>>> On 17 Oct 2014, at 18:15, Annick Fron <list(a)afceurope.com> wrote:
> >>>>>>
> >>>>>>> Thank you, but I am confused.
> >>>>>>> I have checked your NTP code, and it uses
> >>>>>>> sendUDPData and not sendData. Same for receiveUDPData.
> >>>>>>> Besides how is it possible to know where the message comes from in a broadcast mode ??
> >>>>>>> Annick
> >>>>>>> Le 17 oct. 2014 à 17:35, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit :
> >>>>>>>
> >>>>>>>> UDP is pretty easy, just send and receive byte arrays basically, mostly non-blocking.
> >>>>>>>>
> >>>>>>>> http://forum.world.st/UDP-Listener-example-td4362851.html
> >>>>>>>> http://forum.world.st/SysLogSender-UDP-td4745862.html
> >>>>>>>>
> >>>>>>>> The API is all in Socket.
> >>>>>>>>
> >>>>>>>> On 17 Oct 2014, at 17:09, Annick Fron <list(a)afceurope.com> wrote:
> >>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I was not able to find a UDP example in pharo.
> >>>>>>>>>
> >>>>>>>>> There are only TCP examples.
> >>>>>>>>>
> >>>>>>>>> Any pointer ?
> >>>>>>>>>
> >>>>>>>>> Annick
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
>
>
>
Oct. 21, 2014
Mac sqDecryptSSL returning SQSSL_GENERIC_ERROR on errSSLClosedGraceful from SSLRead
by Kris Gybels
I'm wondering whether the Mac SSL plugin is correct in returning SQSSL_GENERIC_ERROR from sqDecryptSSL when its SSLRead invocation returns errSSLClosedGraceful.
I'm trying to figure out why ZdcSecureSocketStream is sometimes signaling an error âError: SSL Exception: decrypt failed [code:-5]â. I enabled logging in the SSL plugin and got the following output:
[...]
sqDecryptSSL: Input data 0 bytes
sqDecryptSSL: Decrypting 69 bytes
SqueakSSLRead: Requesting 5 bytes, having 69 bytes
SqueakSSLRead: Requesting 64 bytes, having 64 bytes
SqueakSSLWrite: Writing 69 bytes, having 16971 free
sqDecryptSSL: SSLRead returned -9805
Error: SSL Exception: decrypt failed [code:-5]
ZdcSecureSocketStream(Object)>>error:
ZdcSecureSocketStream>>sslException:code:
ZdcSecureSocketStream>>fillBytes:startingAt:count: in Block: [ ...
ZdcSecureSocketStream>>fillBytes:startingAt:count:
[...]
The related code in the SSL plugin is the sqDecryptSSL function on lines 355-387 in sqMacSSL.c; -5 is SQSSL_GENERIC_ERROR defined on line 22 of SqueakSSL.h:
https://code.google.com/p/squeakssl/source/browse/src/Mac%20OS/sqMacSSL.c#3…
https://code.google.com/p/squeakssl/source/browse/src/Cross/SqueakSSL.h#22
The above log shows that the SSLRead invocation on line 383 returned -9805 which is errSSLClosedGraceful:
https://developer.apple.com/library/mac/documentation/Security/Reference/se…
I'm not really sure what this status code means, but the description âclosed gracefullyâ (as opposed to the description âclosed due to an errorâ for errSSLClosedAbort) makes me wonder whether sqDecryptSSL shouldn't handle this status code as something other than an error?
Oct. 21, 2014
Re: [Pharo-users] UDP example
by Luc Fabresse
yes examples are good.
but I also suggest to use a stream on a UDPSocket instead of manipulating
the socket directly in the model code.
Usually, it lowers the code complexity.
Luc
2014-10-21 10:36 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> OK good.
>
> I think it would be best to add some examples to the image:
>
>
> https://pharo.fogbugz.com/f/cases/14275/Add-some-decent-TCP-UDP-examples-an…
>
> I will do that in the coming days.
> > On 21 Oct 2014, at 10:20, Annick Fron <list(a)afceurope.com> wrote:
> >
> > OK super, this example works. I got confused because I did not
> understand that you had 2 variables, buffer passed as argument and result
> as return.
> >
> > Annick
> > Le 21 oct. 2014 à 09:53, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit :
> >
> >> The buffer that you supply to #receiveUDPDataInto: is either a String
> or a ByteArray, preallocated to a certain size. It gets filled with the
> incoming data part of the datagram. It should be large enough, it never
> overflows, if it is too small, you simply miss data (it is lost). If you
> preallocate N bytes, the result, the incoming data, might be less.
> >>
> >> The result from #receiveUDPDataInto: is a 4 element array, that I
> described before. The fields you are looking for are in the second (the ip
> address of the sender, a 4 element byte array) and in third (the port of
> the sender) slot. The first element is the actual number of bytes read. You
> need to copy from 1 to that size out of the buffer.
> >>
> >> The other fields that are in a datagram, outside the user data, are not
> accessible. You don't need them, unless you are implementing a TCP/IP stack
> yourself.
> >>
> >> Did you try this example ?
> >>
> >> "An UDP echo server on port 6666"
> >> [ Socket newUDP in: [ :socket |
> >> | loop buffer result input |
> >> buffer := String new: 256.
> >> loop := true.
> >> socket setPort: 6666.
> >> [ loop ] whileTrue: [
> >> [ result := socket receiveUDPDataInto: buffer.
> >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> >> input := buffer copyFrom: 1 to: result first.
> >> socket sendUDPData: input toHost: result second port: result third.
> >> (input beginsWith: #quit) ifTrue: [ loop := false ] ].
> >> socket closeAndDestroy ] ] forkAt: Processor userBackgroundPriority
> named: 'UDP echo server'.
> >>
> >> "Any message sent gets echoed back"
> >> Socket newUDP in: [ :socket |
> >> | buffer result |
> >> socket sendUDPData: 'testing ', 99 atRandom asString toHost:
> NetNameResolver localHostAddress port: 6666.
> >> buffer := String new: 256.
> >> [ result := socket receiveUDPDataInto: buffer.
> >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> >> socket closeAndDestroy.
> >> { result. buffer. buffer copyFrom: 1 to: result first } ].
> >>
> >> "Send quit to stop the server"
> >> Socket newUDP in: [ :socket |
> >> | buffer result |
> >> socket sendUDPData: 'quit' toHost: NetNameResolver localHostAddress
> port: 6666.
> >> buffer := String new: 256.
> >> [ result := socket receiveUDPDataInto: buffer.
> >> result first > 0 ] whileFalse: [ (Delay forMilliseconds: 10) wait ].
> >> socket closeAndDestroy.
> >> { result. buffer. buffer copyFrom: 1 to: result first } ].
> >>
> >> In a terminal (OSX or Linux), you can send a message like this:
> >>
> >> $ nc -u 127.0.0.1 6666
> >> foo bar
> >> foo bar
> >> quit
> >> quit
> >>
> >>> On 21 Oct 2014, at 09:31, Annick Fron <list(a)afceurope.com> wrote:
> >>>
> >>> Sven,
> >>>
> >>> I have put a halt in your sync method, but receiveUDPData comes with
> 64 bytes in your app, whereas you have provisioned 48 bytes.
> >>> So since you start data at 33, I guess what you receive is the usual
> datagram IP header on 16 bytes, then the UDP header on 16 bytes.
> >>>
> http://fr.wikipedia.org/wiki/Internet_Protocol#mediaviewer/File:Ipv4_header…
> >>> http://fr.wikipedia.org/wiki/User_Datagram_Protocol
> >>>
> >>> If this is correct, I should see the source IP address on 4 bytes
> starting at byte 9, and the total length should be on 4 bytes starting at
> byte 5, and not at byte 1.
> >>>
> >>> Annick
> >>>
> >>> Le 20 oct. 2014 à 17:29, Sven Van Caekenberghe <sven(a)stfx.eu> a écrit
> :
> >>>
> >>>> Annick,
> >>>>
> >>>>> On 20 Oct 2014, at 17:12, Annick Fron <list(a)afceurope.com> wrote:
> >>>>>
> >>>>> Thank you but your explanation does not explain what is the type
> (signed unsigned) and the size of each header component.
> >>>>> Thus it is impossible to work with that.
> >>>>
> >>>> I think you are making this way more difficult than it is.
> >>>>
> >>>> ZTimestampSNTPClient>>#sync contains a simple, runnable example of
> using datagrams (with a busy wait blocking the calling thread, which is
> only good for something simple, because normally datagrams are
> asynchronous, but that is another story).
> >>>>
> >>>> What you get back from #receiveUDPDataInto: is an Array with 4
> elements:
> >>>>
> >>>> - number of bytes received, Integer
> >>>> - address of sender, ByteArray (use NetNameResolver if necessary)
> >>>> - port of sender, Integer
> >>>> - whether more datagrams are available for reading, Boolean
> >>>>
> >>>> The data is in the reallocated buffer that you supplied,
> aStringOrByteArray.
> >>>>
> >>>> This is all perfectly useable at the Pharo level.
> >>>>
> >>>> The question about signed/unsigned sounds like a C question, for
> which this is the wrong list, no ? I am sure it is quite easy to find C
> code that works with datagrams on your platform. A byte array is an
> unsigned char array as far as I remember ...
> >>>>
> >>>> What you put inside the datagram, is up to you and your application.
> >>>>
> >>>> HTH,
> >>>>
> >>>> Sven
> >>>>
> >>>>> Annick
> >>>>>
> >>>>> Le 17 oct. 2014 Ã 19:09, Sven Van Caekenberghe <sven(a)stfx.eu> a
> écrit :
> >>>>>
> >>>>>> Yes, you have to use the methods in the protocol 'datagrams' of
> Socket.
> >>>>>>
> >>>>>> When you receive a datagram, the IP:PORT of the other party is
> included, see #receiveUDPDataInto:'c comment.
> >>>>>>
> >>>>>> It is all a bit low level, but it works well.
> >>>>>>
> >>>>>> On 17 Oct 2014, at 18:15, Annick Fron <list(a)afceurope.com> wrote:
> >>>>>>
> >>>>>>> Thank you, but I am confused.
> >>>>>>> I have checked your NTP code, and it uses
> >>>>>>> sendUDPData and not sendData. Same for receiveUDPData.
> >>>>>>> Besides how is it possible to know where the message comes from in
> a broadcast mode ??
> >>>>>>> Annick
> >>>>>>> Le 17 oct. 2014 Ã 17:35, Sven Van Caekenberghe <sven(a)stfx.eu> a
> écrit :
> >>>>>>>
> >>>>>>>> UDP is pretty easy, just send and receive byte arrays basically,
> mostly non-blocking.
> >>>>>>>>
> >>>>>>>> http://forum.world.st/UDP-Listener-example-td4362851.html
> >>>>>>>> http://forum.world.st/SysLogSender-UDP-td4745862.html
> >>>>>>>>
> >>>>>>>> The API is all in Socket.
> >>>>>>>>
> >>>>>>>> On 17 Oct 2014, at 17:09, Annick Fron <list(a)afceurope.com> wrote:
> >>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I was not able to find a UDP example in pharo.
> >>>>>>>>>
> >>>>>>>>> There are only TCP examples.
> >>>>>>>>>
> >>>>>>>>> Any pointer ?
> >>>>>>>>>
> >>>>>>>>> Annick
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>
> >
>
>
>
Oct. 21, 2014
Re: [Pharo-users] new Pharo Success story
by Esteban A. Maringolo
Not right now, but if I could, how can I collaborate with that?
So instead of one Esteban, you can have two :)
Esteban A. Maringolo
2014-10-21 3:48 GMT-03:00 stepharo <stepharo(a)free.fr>:
> I agree but I prefer that esteban works on spur.
>
> Stef
>
>
> On 20/10/14 17:43, Esteban A. Maringolo wrote:
>>
>> 2014-10-20 6:41 GMT-03:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
>>
>>> It is a lot of work to do a project inside such a big bank, let alone
>>> make a success of it.
>>> Congratulation to Tomas and the rest of his team.
>>
>> +1
>>
>> suggestion: can the success page be splitted into different pages?
>> I prefer a main success page with the logos and/or excerpts of the
>> solutions linking to the full success page case.
>>
>> Regards!
>>
>>
>> Esteban A. Maringolo
>>
>>
>
>
Oct. 21, 2014
Re: [Pharo-users] How to see output of printf invocations in VM plugins
by Kris Gybels
> Have you tried running the VM from the command line ?
> I would think the output of stdout would appear there.
I thought I'd tried this and didn't get the plugin output.
But I tried again and it does indeed show the plugin output. Must've done something wrong before. Thanks!
Oct. 21, 2014