0

I am looking for a WebSocket Server API (for any platform and written on any language) with blocking writing operations. All implementations I've seen so far just have async-io methods.

What I need is to have blocking send functions to know when the information has been completely sent (send buffer is empty) and/or have access to related tcp layer information, such as the queue length of the sender buffer and RTT, without using any ACKs or replies from the client.

Is there such an implementation I can use, or should I implement it myself on top of a TCP socket?

Silvia
  • 269
  • 2
  • 5
  • 17
  • What real problem are you actually trying to solve? – jfriend00 Jan 28 '15 at 23:08
  • I want to be aware of how long it takes to send a file from server to client over websockets and calculate the throughput without using replies from the client, thus only on server side – Silvia Jan 28 '15 at 23:14
  • 1
    There are no such blocking-write functions at the TCP level, let alone a WebSocket Server API level, unless some such Windows trick as a [zero-length send buffer](https://msdn.microsoft.com/en-us/library/windows/desktop/ms740550(v=vs.85).aspx) works for you. However, delivery from the local socket send buffer is only to the peer's socket receive buffer. You have no knowledge of when the peer *application* has read all the data. So it isn't clear that such an API or usage would actually meet the requirement you stated in your comment. In any case search/recommend questions are off topic. – user207421 Jan 28 '15 at 23:21

1 Answers1

0

You can use golang websocket lib (https://github.com/gorilla/websocket) or writing your own websocket lib with linux syscall to do "blocking" network operations. But they only blocked when the system tcp buffer is full, not block and unblock after the peer received all the data. If the system tcp buffer is not full, that write syscall will return less then 1 millisecond. This system tcp buffer full blocking stuff may fulfill your need if you send a very large size of data.

If you want to block and unblock after the peer received all the data, then you requirement is not meet with tcp/websocket protocol directly.

You can only know your peer receive all your data after it send you an ack back from your own protocol.

Of course you can write a protocol that write operation can unblock after the peer read all data and the peer application comfired it with your api, but that protocol is not tcp/websocket protocol.

Please note that even if you can get the tcp ack packet, you can not know when the process of another peer have processed all your data(like store them in a file). You have to design an api that peer can tell the protocol that it processed all your data.

bronze man
  • 1,470
  • 2
  • 15
  • 28