How can I combine strings > 64kb without exceeding the string limit?

So I’m transferring data from client to server via the net library.
I basically start with a huge string, then chop it up into substrings each 64kb each and loop until all the data is sent.
Then it is received by the server, and I need to know how to combine it without overflowing the 64kb limit.

Any ideas? Thanks.

Would post the code, but it’s rather long and pretty redundant.

[editline]30th May 2013[/editline]

Nevermind. I just found out that net messages sent can’t be larger than 64kb even if you use multiple net.WriteString()'s.

What on earth are you transferring that requires >64kb strings?


I’m trying to send the player’s screen data over several strings and then concatenate them to view it. Even with jpeg quality at 10, it’s still about 80-110kb.

[editline]30th May 2013[/editline]

Anyways, Does anybody know a good way to break up the data clientside and send it to the server and then combine it again?


Something like:
[lua]local Packets = {}
local Str = “aaabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzzz”
function BreakUp(str,len)
n = math.ceil(string.len(str)/len)
for I=1,n do
Packets* = string.sub(str,(I-1)len,Ilen-1)
print("Number of packets: "…#Packets)
for I=1,#Packets do

BreakUp(string,Max length of each packet)

Send more than 1 message. Give each message a small header telling you all of the important information that you need to know to reconstruct it on the receiving end. For instance, you could start each message with two 8 bit integers to tell you which segment of the data that the message represents, and the total number of segments. Store the segments on the receiving end, and assemble them after you get all of them. If you can, try to add a delay between sending each message to avoid possible ‘overflowed reliable channel’ errors. Make sure your code can handle getting them out of order, as that can happen on the internet.

I like that idea, that’s pretty much what I needed thanks.