TCP and UDP streams / buffers

Blitz3D Forums/Blitz3D Programming/TCP and UDP streams / buffers

Chaduke(Posted 2005) [#1]
I've been experimenting with the TCP and UDP networking functions in Blitz3D and have some basic examples working. I'm curious about how streams and buffers work internally though. I want to make sure I'm "cleaning up" properly and not being wasteful when designing clients and servers.

At the moment my most important questions are with UDP.
On the client side I create a UDP stream. I then write things to it, bytes, integers, floats, and strings. I then send a message to the server referencing this stream and the data gets sent.
At this point, what happens to the stream? Is it automatically cleared or is there a reference pointer of some sort that gets set? Say at this point I write some more data to the stream and then send another message. Has the stream grown more thus taking up more memory? Also, does the send message function automatically know from where in the stream to start sending data?
Now, on the server side, I create a UDP stream, accept a UDP message which in turn writes to the stream of data. I then read the data from the stream and use it however I want. When I recieve another message with this stream, is data appended to it?
I'm mainly wondering if I have to somehow manually clear the data in these streams so they don't end up taking huge amounts of memory over time.


BIG BUG(Posted 2005) [#2]
At this point, what happens to the stream?

It's cleared, so only new data gets sent.

When I receive another message with this stream, is data appended to it?

No, you have to use RecvUDPMsg for each "packet". Repeat RecvUDPMsg and your receiving code, until returncode is zero.