feklee
feklee

Reputation: 7695

TCPSocket.send: What happens when the buffer is full?

From the documentation of TCPSocket.send:

  • If send returns true, then less than 64k has been buffered and it's safe to immediately write more.

  • If send returns false, then more than 64k has been buffered, and the caller may wish to wait until the drain event has been triggered before buffering more data by more calls to send.

This tells the program what best to do next in order to avoid a buffer overflow.

What happens if the buffer is already full? Can the program check whether the buffer is full before sending data?

Upvotes: 0

Views: 229

Answers (1)

Jason Weathersby
Jason Weathersby

Reputation: 1081

I have not tried this but have you looked at the TCPSocket.bufferedAmount property? TCP Socket. From this article: "It's possible to know exactly the current amount of data buffered with the TCPSocket.bufferedAmount property."

Upvotes: 1

Related Questions