Closed folkertvanheusden closed 1 year ago
I can't test it in now, but isn't it also necessary to explicitly flush the output so we are sure, that the concatenated message is send immediately?
https://stackoverflow.com/questions/855544/is-there-a-way-to-flush-a-posix-socket
Also in case of Linux, TCP_CORK
would be probably a better choice. (And subsequent toggeling in flush
callback)
I've tested in a toy-project of mine, and TCP_CORK also solves it:
size_t SCPI_Write(scpi_t * context, const char * data, size_t len) {
if (context->user_context != NULL) {
int fd = ((audio_dev_t *)context->user_context)->fd;
int state = 1;
setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
return write(fd, data, len);
}
return 0;
}
scpi_result_t SCPI_Flush(scpi_t * context) {
if (context->user_context != NULL) {
int fd = ((audio_dev_t *)context->user_context)->fd;
int state = 0;
setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
}
return SCPI_RES_OK;
}
Thanks for the help!
The problem of the fragmented *IDN? response can be mitigated somewhat by enabling nagle during the response to that command.