QTcpSocket write behavior when large num of bytes are written
-
Standard linux/windows sockets in non-blocking mode return EWOULDBLOCK when a large buffer is written and then we have to wait for the socket to be writable again via epoll/select. Whats the correct procedure to do the same with QTcpSocket? I only see readyRead event in documentation.
-
@Taytoo You can use https://doc.qt.io/qt-5/qiodevice.html#bytesWritten signal to see how many bytes where written.
-
@aha_1980 said in QTcpSocket write behavior when large num of bytes are written:
@Taytoo QTcpSocket has an internal write buffer and takes care of the OS limitations; just make sure not to overrun the internal buffer (which is 2GB AFAIK).
It's an interesting design, while it makes it easy to use qtcpsocket, the problem is that the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time.
-
@Taytoo said in QTcpSocket write behavior when large num of bytes are written:
the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time
If that's what you want your program to do, then write it!
If you want to monitor at low-level outside, use a tool like wireshark.
-
@Taytoo said in QTcpSocket write behavior when large num of bytes are written:
the program won't have any idea how performant the underlying connection is unless we monitor the bytesWritten event and keep track of how much data is pending at any given time
Think about the multi-platform capability of Qt framework, so for lots of developers such OS details independence is a blessing...
As mentioned in other replies, if you require a super-duper specific kinda low level functionality for a particular OS, you may want to do your own approach. Keep in mind that you can still "mix and match" Qt and some other support libraries. I mean, you can still have all the benefits of Qt GUI for instance, and have your own network module working together.