Use TCP_CORK instead of Nagle to control flushing
| | |
| | | #include "../common/scpi-def.h" |
| | | |
| | | size_t SCPI_Write(scpi_t * context, const char * data, size_t len) { |
| | | (void) context; |
| | | |
| | | if (context->user_context != NULL) { |
| | | int fd = *(int *) (context->user_context); |
| | | |
| | | 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) { |
| | | (void) context; |
| | | if (context->user_context != NULL) { |
| | | int fd = *(int *) (context->user_context); |
| | | |
| | | int state = 0; |
| | | setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state)); |
| | | } |
| | | |
| | | return SCPI_RES_OK; |
| | | } |
| | |
| | | listenfd = createServer(5025); |
| | | |
| | | while (1) { |
| | | int clifd, flag = 0; |
| | | int clifd, flag = 1; |
| | | struct sockaddr_in cliaddr; |
| | | socklen_t clilen; |
| | | |