Re: [Pharo-users] UDP example

2014-10-21 Thread Sven Van Caekenberghe
> On 21 Oct 2014, at 17:53, Annick Fron wrote: > > > 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. > I

Re: [Pharo-users] UDP example

2014-10-21 Thread 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 :-

Re: [Pharo-users] UDP example

2014-10-21 Thread Henrik Johansen
> On 21 Oct 2014, at 3:52 , Luc Fabresse wrote: > > > > 2014-10-21 15:40 GMT+02:00 Sven Van Caekenberghe >: > > > On 21 Oct 2014, at 15:29, Luc Fabresse > > wrote: > > > > > > yes examples are good. > > but I also suggest to use a stream o

Re: [Pharo-users] UDP example

2014-10-21 Thread Luc Fabresse
2014-10-21 15:40 GMT+02:00 Sven Van Caekenberghe : > > > On 21 Oct 2014, at 15:29, Luc Fabresse 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 complexi

Re: [Pharo-users] UDP example

2014-10-21 Thread Sven Van Caekenberghe
> On 21 Oct 2014, at 15:29, Luc Fabresse 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

Re: [Pharo-users] UDP example

2014-10-21 Thread 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 : > OK good. > > I think it would be best to add some examples to t

Re: [Pharo-users] UDP example

2014-10-21 Thread Sven Van Caekenberghe
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-and-tests I will do that in the coming days. > On 21 Oct 2014, at 10:20, Annick Fron wrote: > > OK super, this example works. I got confused because I

Re: [Pharo-users] UDP example

2014-10-21 Thread Annick Fron
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 a écrit : > The buffer that you supply to #receiveUDPDataInto: is either a String or a > By

Re: [Pharo-users] UDP example

2014-10-21 Thread Sven Van Caekenberghe
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 prealloca

Re: [Pharo-users] UDP example

2014-10-21 Thread Annick Fron
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/wi

Re: [Pharo-users] UDP example

2014-10-20 Thread Sven Van Caekenberghe
Annick, > On 20 Oct 2014, at 17:12, Annick Fron 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. ZTimesta

Re: [Pharo-users] UDP example

2014-10-20 Thread Annick Fron
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. Annick Le 17 oct. 2014 à 19:09, Sven Van Caekenberghe a écrit : > Yes, you have to use the methods in the protocol 'datagrams' of S

Re: [Pharo-users] UDP example

2014-10-17 Thread Sven Van Caekenberghe
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 wrote: > Thank you, but I am

Re: [Pharo-users] UDP example

2014-10-17 Thread Sven Van Caekenberghe
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 wrote: > Hi, > > I was not abl

Re: [Pharo-users] UDP example

2014-10-17 Thread Annick Fron
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 a écrit : > UDP is pretty e