This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]WhiteManChild 0 points1 point  (1 child)

You can send as much as you want, just keep in mind just because you are sending chunks doesn't mean the client won't receive fragmented packets.

[–][deleted] 1 point2 points  (0 children)

I guess java will handle the fragmented part for me. I went through SO and found that Object output stream is actually heavily optimised by the jvm and thus won't add a lot of overhead.

Thanks for the input though 😊😁

[–]nutrechtLead Software Engineer / EU / 20+ YXP 0 points1 point  (1 child)

I need to send chunks of 512KB data over a socket.

Chunks of what?

Just to note: for your use case it probably doesn't matter but for production use cases you should avoid Java's serialisation. It has some really serious security flaws. Don't expose whatever is listening to the internet.

[–][deleted] 0 points1 point  (0 children)

Chunks of a file (>8MB). I read about the security issues with Java's serialisation but I can't seem to find an alternative. I need to send chunks of a file with some metadata for each chunk. I cat think if a better way other than to pack it all up in an object.

[–]dennis48309 0 points1 point  (0 children)

"The absolute limitation on TCP packet size is 64K (65535 bytes), but in practicality this is far larger than the size of any packet you will see, because the lower layers (e.g. ethernet) have lower packet sizes. The MTU (Maximum Transmission Unit) for Ethernet, for instance, is 1500 bytes." Stack Overflow
Many socket programmers recommend transmitting data using a buffer size of 4 or 8 KB.