recv

C++ nonblocking sockets - wait for all recv data

痞子三分冷 提交于 2021-02-10 11:49:06
问题 I wasn't running into this problem on my local system (of course), but now that I am setting up a virtual server, I am having some issues with a part of my code. In order to receive all data from a nonblocking TCP recv(), I have this function ssize_t Server::recvAll(int sockfd, const void *buf, size_t len, int flags) { // just showing here that they are non-blocking sockets u_long iMode=1; ioctlsocket(sockfd,FIONBIO,&iMode); ssize_t result; char *pbuf = (char *)buf; while ( len > 0 ) { result

C++ nonblocking sockets - wait for all recv data

↘锁芯ラ 提交于 2021-02-10 11:49:01
问题 I wasn't running into this problem on my local system (of course), but now that I am setting up a virtual server, I am having some issues with a part of my code. In order to receive all data from a nonblocking TCP recv(), I have this function ssize_t Server::recvAll(int sockfd, const void *buf, size_t len, int flags) { // just showing here that they are non-blocking sockets u_long iMode=1; ioctlsocket(sockfd,FIONBIO,&iMode); ssize_t result; char *pbuf = (char *)buf; while ( len > 0 ) { result

UDP non-blocking socket on a real-time OS: sendto() and recvfrom() can return with partial message?

百般思念 提交于 2021-02-08 04:38:47
问题 This is my first message here. I'm working with a non-blocking UDP socket on a real-time OS (OnTime and VxWorks). I have read the documentation and some forums but I have some doubts about 'atomicity' of sendto() and recvfrom() functions: sendto() returns the number of bytes enqueued or error. Is it possible that it's less then the input buffer length? Maybe the output buffer has not enough free space and just few bytes are enqueued... recvfrom() returns the number of byte received or error.

Python blocking recv returns less data than asked for

半腔热情 提交于 2021-01-28 22:07:21
问题 I have an echo server in C and a test client in Python. The server has a limited read buffer, eg 16bytes. When a client send more than 16 bytes, it will first read 16, write back to client and then read again. I tested the server with telnet , and I got back the same string as my input, even it's longer than 16 bytes. However this Python client does not work. //data is initialized to be 20 bytes data Len = 20 sock.setblocking(1) sock.send(data) recvdata = sock.recv(Len) if(recvdata != data):

Python blocking recv returns less data than asked for

穿精又带淫゛_ 提交于 2021-01-28 21:14:40
问题 I have an echo server in C and a test client in Python. The server has a limited read buffer, eg 16bytes. When a client send more than 16 bytes, it will first read 16, write back to client and then read again. I tested the server with telnet , and I got back the same string as my input, even it's longer than 16 bytes. However this Python client does not work. //data is initialized to be 20 bytes data Len = 20 sock.setblocking(1) sock.send(data) recvdata = sock.recv(Len) if(recvdata != data):

Linux socket: How to make send() wait for recv()

无人久伴 提交于 2021-01-20 18:14:30
问题 I am making a simple client-server application using TCP protocal. I Know that by default. recv() will block until the other side call a send() to this socket. But is it possible that send() block itself until the other side has recv() ed the msg instead of keeping send() ing to outgoing queue and later to find the other side recv() got a whole bunch of msg sent by multiple send() s In other words. Is it possible to let every send() wait for the other side's recv() before it can call another

C++ How can I send an object via socket?

眉间皱痕 提交于 2020-11-26 19:41:12
问题 I have a question for you. I have this class: ` #define DIMBLOCK 128 #ifndef _BLOCCO_ #define _BLOCCO_ class blocco { public: int ID; char* data; blocco(int id); }; #endif blocco::blocco(int id) { ID = id; data = new char[DIMBLOCK]; } ` and the application has a client and a server. In the main of my server I instantiate an object of this class in this way: blocco a(1); After that I open a connection between the client and the server using sockets. The question is: how can I send this object

C++ How can I send an object via socket?

我是研究僧i 提交于 2020-11-26 19:33:58
问题 I have a question for you. I have this class: ` #define DIMBLOCK 128 #ifndef _BLOCCO_ #define _BLOCCO_ class blocco { public: int ID; char* data; blocco(int id); }; #endif blocco::blocco(int id) { ID = id; data = new char[DIMBLOCK]; } ` and the application has a client and a server. In the main of my server I instantiate an object of this class in this way: blocco a(1); After that I open a connection between the client and the server using sockets. The question is: how can I send this object

C++ How can I send an object via socket?

丶灬走出姿态 提交于 2020-11-26 19:31:10
问题 I have a question for you. I have this class: ` #define DIMBLOCK 128 #ifndef _BLOCCO_ #define _BLOCCO_ class blocco { public: int ID; char* data; blocco(int id); }; #endif blocco::blocco(int id) { ID = id; data = new char[DIMBLOCK]; } ` and the application has a client and a server. In the main of my server I instantiate an object of this class in this way: blocco a(1); After that I open a connection between the client and the server using sockets. The question is: how can I send this object