BSD Sockets function used for receiving data from a TCP socket.
Questions tagged [recv]
670 questions
4
votes
1 answer
Does recv remove packets from pcaps buffer?
Say there are two programs running on a computer (for the sake of simplification, the only user programs running on linux) one of which calls recv(), and one of which is using pcap to detect incoming packets. A packet arrives, and it is detected by…

Benubird
- 18,551
- 27
- 90
- 141
4
votes
5 answers
epoll_wait() receives socket closed twice (read()/recv() returns 0)
We have an application that uses epoll to listen and process http-connections. Sometimes epoll_wait() receives close event on fd twice in a "row". Meaning: epoll_wait() returns connection fd on which read()/recv() returns 0. This is a problem, since…

Antti Partanen
- 41
- 1
- 2
4
votes
3 answers
recv receiving not whole data sometime
I have following issue: here is the chunk of code:
void get_all_buf(int sock, std::string & inStr) {
int n = 1;
char c;
char temp[1024*1024];
bzero(temp, sizeof(temp));
n = recv(sock, temp, sizeof(temp), 0);
inStr =…

milo
- 1,220
- 3
- 17
- 33
4
votes
1 answer
Why is there no flag like MSG_WAITALL for send?
The flag MSG_WAITALL can be used for recv, which requests recv to block until the full request is satisfied. That means recv will not return until as much data as requested (specified by the argument len) has been received, unless an error occurs or…

xiaokaoy
- 1,608
- 3
- 15
- 27
4
votes
3 answers
How to turn a character array into uint8_t
I have a server-client application that I'm working on that basically simulates a chat room. This is an assignment for school and the protocol specifications are somewhat strict.
I have a char array which will store all messages from a client.
The…

fatalError
- 305
- 2
- 4
- 17
4
votes
2 answers
Winsock local loop-back latency
I'm using tcp sockets to provide interprocess communication between two apps on Windows XP. I chose tcp sockets for various reasons. I'm seeing an average round-trip time of 2.8 ms. That's much slower than I was expecting. Profiling seems to show…

Andrew Bainbridge
- 4,651
- 3
- 35
- 50
4
votes
2 answers
Does python's recvfrom() queue packets?
My impression was recvfrom() gave you the next packet on the IP and port it is listening on, and if it is not listening packets get missed. We are having an issue where the problem could be packets are queued up for recvfrom(), therefore it is…

gaucho
- 55
- 5
4
votes
2 answers
Determine how many bytes can be sent with winsock (FIONWRITE)?
With select I can determine if any bytes can be received or sent without blocking.
With this function I can determine how many bytes can be received:
function BytesAvailable(S: TSocket): Integer;
begin
if ioctlsocket(S, FIONREAD, Result) =…

tim93
- 109
- 2
- 7
4
votes
5 answers
How to avoid DOS attack in this code?
I have a code written in C/C++ that look like this:
while(1)
{
//Accept
struct sockaddr_in client_addr;
int client_fd = this->w_accept(&client_addr);
char client_ip[64];
int client_port = ntohs(client_addr.sin_port);
…

user840718
- 1,563
- 6
- 29
- 54
3
votes
2 answers
How would you receive a file sent with 'sendfile'?
I'm trying to implement a basic file server. I have been trying to use the sendfile command found here: http://linux.die.net/man/2/sendfile I'm using TCP.
I can have it send fine, but its sending in binary and I'm not sure if thats the hang up.
I…

user974703
- 1,653
- 4
- 20
- 27
3
votes
1 answer
How to know which case happens when nonblocking recv returns 0?
I have simple TCP server that runs with non-blocking sockets.
Quote from manpage of recv;
When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional "end-of-file" return).
The value 0 may also be…

fakwjdkawjdawk
- 35
- 4
3
votes
2 answers
Python tcp send receive functions
In python the recv is a blocking function or not? I'm learned in the Uni C and there the was blocking and non-blocking socket. So I just wan to ask weather in python the recv function is a blocking function or not.

Mokus
- 10,174
- 18
- 80
- 122
3
votes
4 answers
Is acknowledgment response necessary when using send()/recv() of Winsock?
Using Winsock, C++, I send and receive the data with send()/recv(), TCP connection. I want to be sure that the data has been delivered to the other party, and wonder if it is recommended to send back some acknowledgment message after (if) receiving…

TX_
- 83
- 1
- 5
3
votes
0 answers
Python Socket How to get a continuous stream of data with recv in a thread?
So I'm trying to write a program that gets a continuous stream of data from a server, in a thread. The data being sent from the server is always very short, but does range in length
I'm currently trying to use the recv function in the socket library…

MiloTier
- 31
- 4
3
votes
1 answer
Optimal Sizes of data for sends and receives in MPI
I am writing a parallel application with MPI in which the master process has data of size approximately as large as the cache(4MB on the platform I am working on) to send over to each process. As 4MB might be too large for the master to send at a…

cpp_noname
- 2,031
- 3
- 17
- 30