| | |
| | | #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; |
| | | } |
| | |
| | | /* |
| | | * |
| | | */ |
| | | |
| | | //网络通信部分可以不使用标准C的socket通信,可以采用C++或者Qt的网络库进行传输 |
| | | int main(int argc, char** argv) { |
| | | (void) argc; |
| | | (void) argv; |
| | |
| | | listenfd = createServer(5025); |
| | | |
| | | while (1) { |
| | | int clifd, flag = 0; |
| | | int clifd, flag = 1; |
| | | struct sockaddr_in cliaddr; |
| | | socklen_t clilen; |
| | | |