Dynamic buffer for WebSocket::receiveBuffer()

Discussion of ideas for features and new projects based on POCO.
Posts: 4
Joined: 12 Oct 2012, 06:09

Dynamic buffer for WebSocket::receiveBuffer()

Postby wisesteve » 16 Oct 2012, 22:27

WebSocket::receiveFrame(void* buffer, int length, int& flags) writes the received frame into a buffer statically assigned by the caller, and throws if it sees a websocket frame larger than that buffer. There's no general "good size" for that buffer as messages will often be small, but if there's any chance of an application using a large frame occasionally you'll need to allocate a very large buffer that'll seldom be used.

The size of a websocket frame is encoded in the first few bytes of the packet, so it would be a fairly minor change to support returning a dynamically assigned buffer instead, either by allowing receiveFrame() to realloc a buffer passed to it, or by allocating something like std::string inside receiveFrame(), something like this:

Code: Select all

std::string WebSocket::receiveFrame(int& flags)
int WebSocket::sendFrame(std::string buffer, int flags)

Transparent reassembly of fragmented packets might be useful too.

Return to “Wishlist”

Who is online

Users browsing this forum: No registered users and 1 guest