Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
idudpserver max length ?
i am trying to send a string length more than 9000 to idudpserver but seems idudpserver does not receive more than 1000 length any idea why ?
UDP is a datagram-based transport. There is a 1:1 relationship between the size of the data being sent and the size of the data being received. The default value of the TIdUDPServer.BufferSize property is 8192 bytes, so right there, that is not enough buffer space to receive 9000 characters. You need to increase the BufferSize.

The TIdUDPServer.OnUDPRead event is only fired for datagrams that are received in full, partial datagrams that get truncated due to lack of buffer space are ignored and discarded.

What is the actual encoding of the strings you are sending? Using a packet sniffer, like Wireshark, what is the actual byte size of the datagrams that are not being received correctly? UDP has a maximum payload size of 65507 bytes.

that data that i am trying to send is in base64 encode UTF-8 Format

the byte size is 14069

i am not sure about the correct buffer size that i have to set
You are not sending 9000 string characters as-is, you are encoding them as UTF-8, which expands the byte size if there are non-ASCII characters present, and then you are encoding that with base64 (why?), which expands the byte size by 3/2 times. So, a 9000 character string would be AT LEAST 13500 bytes and AT MOST 54000 bytes, depending on what the characters actually are and how UTF-8 encodes them.

Those sizes are larger than the default BufferSize of 8192 bytes, which is why you are not seeing that datagram arrive in the OnUDPRead event.

You need to set the BufferSize to a value that can accommodate the largest message that will ever be received. I would suggest setting it to 64K (65536), then you don't have to ever worry about any datagrams being dropped for being too large, as UDP cannot physically hold that many bytes in a single datagram.


Forum Jump:

Users browsing this thread: 1 Guest(s)