> I'm finding that the task of replacing the Mk$ functions with structures > for UDP packet client/server transactions is a massive undertaking. So > far it's affecting every part of my project that constructs, parses, > sends and receives data. As a consequence the network code is going from > dozens of lines to hundreds, and I'm beginning to see that the actual > logic of network operations will need to be changed as well. > ...
Finally I come with a solution. Well I hope. I added three new methods to the Stream class (and so to its child classes: File, Socket, UdpSocket...) in revision #3730. Stream.Begin(), Stream.Send() and Stream.Drop(). All WRITE instructions between a Stream.Begin() and a Stream.Send() will be merged, and send in one shot when Stream.Send() is called. Stream.Drop() just cancels that process. That way, to forge and send a packet to your UdpSocket, instead of doing something like: Write #MyUdpSocket, Chr$(42) & MkShort$(A) & MkInt$(B) & MkFloat$(C) & SomeString ... You will do: MyUdpSocket.Begin Write #MyUdpSocket, 42 As Byte Write #MyUdpSocket, A As Short Write #MyUdpSocket, B As Integer Write #MyUdpSocket, C As Float Write #MyUdpSocket, SomeString, Len(SomeString) MyUdpSocket.Send To read the packet, just use the Read instruction. The UdpSocket already buffers the received packet internally. All that should allow you to do the same thing as before with Mk*() functions, with more lines of code, but with endianness support, without adding too much code to the interpreter. Please tell me that you can do something with that, I have a release candidate to prepare. :-) Regards, -- Benoît Minisini ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user