about the websocket in libdatachannal #1088
-
The WebSocket send interface in libdatachannal, does it copy the data? Is it sent asynchronously? Is it thread-safe? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The method |
Beta Was this translation helpful? Give feedback.
-
thx, the framework now supports custom message sizes |
Beta Was this translation helpful? Give feedback.
The method
send(message_variant data)
does not copy binary data (the library uses move semantics where possible), butsend(const byte *data, size_t size)
does copy the data. The library will attempt to send synchronously: if the data can be sent synchronously,send()
returns true, but if it's not possible because the underlying socket buffer is full (meaning you are sending too fast),send()
returns false, and the data is kept buffered and will be sent it asynchronously when possible. In any case,send()
does not block on network. The method is also thread-safe, meaning you can send concurrently from different threads.