Questions tagged [recv]

BSD Sockets function used for receiving data from a TCP socket.

670 questions
7
votes
3 answers

Can `recv()` result in a buffer overflow?

I'm introducing myself to socket programming in C/C++, and am using send() and recv() to exchange data between a client and server program over TCP sockets. Here are some relevant excerpts from my code: server.c: char recv_data[1024]; // Socket…
DJSunny
  • 1,970
  • 3
  • 19
  • 27
7
votes
1 answer

C - "Transport endpoint is not connected" after first recv() call

I'm just starting to learn network programming in C. I did some tests, but i got stuck with an error. I have a client: client.c #include #include #include #include #include #include…
Sylar
  • 357
  • 1
  • 5
  • 15
7
votes
3 answers

recv() returns 0

I have a very annoying problem that I found several times on other forums but I can't find a proper solution. The problem is recv() returns 0 on the last few bytes of a connection. Here are some background information. Both (client / server)…
HelloWorld
  • 2,392
  • 3
  • 31
  • 68
6
votes
1 answer

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Software caused connection abort: recv failed

all. I have encounter the problem for some days, this is the detail stack information: org.springframework.dao.RecoverableDataAccessException: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:…
Leo
  • 63
  • 1
  • 3
6
votes
2 answers

recv() windows socket takes infinite time - how to timeout?

I use file descriptors to find the readable sockets and go on to read. For some reasons, a socket that has no data on the wire, goes on to read and never returns. Is there a way I can come out of the receive after a timeout? I am using winsock…
ssk
  • 9,045
  • 26
  • 96
  • 169
6
votes
3 answers

socket->recv() vs. <>?

I'm trying to work through a small Perl learning project that requires reading 4 unsigned integers from a socket. I couldn't get more than 1 integer read, and after digging around I found a solution. But I NEED to understand what I didn't do right…
1111000110
  • 93
  • 1
  • 2
  • 6
6
votes
4 answers

Handling multiple recv() calls and all possible scenarios

I am fairly new to C and writing a TCP server, and was wondering how to handle recv()s from a client who will send commands that the server will respond to. For the sake of this question, let's just say header is 1st byte, command identifier is 2nd…
Jack
  • 361
  • 2
  • 4
  • 17
6
votes
3 answers

Sending multiple messages via send() recv(), Socket programming, C

I'm trying to make a program (client) which kan send a message to a server upon request from user. Stripped down code follows: Client: int main(int argc, char **argv) { struct sockaddr_in servaddr; int sock = socket(AF_INET, SOCK_STREAM, 0); …
ragnaroh
  • 344
  • 2
  • 3
  • 12
6
votes
2 answers

Ending "recv()" loop when all information is Read using Winsock

I am having an issue in my recv() loop for winsock. I am trying to terminate the loop when iResult==0, however, the loop only ends when the socket closes. It appears to be hanging at the very last recv() where iResult would equal 0. So any ideas on…
RageD
  • 6,693
  • 4
  • 30
  • 37
6
votes
5 answers

What is the best way to receive data from a socket in Perl, when the data length is unknown?

Right now, I read one character at a time in a loop, until I reach the \0 character. Is there a better way to do this?
Gal Goldman
  • 8,641
  • 11
  • 45
  • 45
6
votes
2 answers

How recv() function works when looping?

I read in MSDN about the send() and recv() function, and there is one thing that I'm not sure I understand. If I send a buffer of size 256 for example, and receive first 5 bytes, so the next time I call the recv() function, it will point to the 6th…
user1386966
  • 3,302
  • 13
  • 43
  • 72
6
votes
0 answers

python multiprocessing pipes how to call callback function if child process sent data through pipe?

Is any callback function exists in python 3 to receive data from child processes without listening to them through Process.recv() or any other block-function? I need that because I have many child processes which can send data to parent process and…
VP.
  • 15,509
  • 17
  • 91
  • 161
6
votes
5 answers

Isn't recv() in C socket programming blocking?

In Receiver, I have recvfd=accept(sockfd,&other_side,&len); while(1) { recv(recvfd,buf,MAX_BYTES-1,0); buf[MAX_BYTES]='\0'; printf("\n Number %d contents :%s\n",counter,buf); counter++; } In Sender , I…
sattu
  • 632
  • 1
  • 22
  • 37
6
votes
4 answers

How to store output of recv()?

In C I had working code but have no idea why it worked, so I started rewriting it so I could actually understand what is going on. So far so good! I rewrote and am 90% sure I understand everything that is going on now; the issue however, is that I…
Keith Miller
  • 1,337
  • 1
  • 16
  • 32
6
votes
2 answers

return value of recv() function in perl

I have non blocking UDP socket in perl created this way my $my_sock = IO::Socket::INET->new(LocalPort => $MY_PORT, Proto => 'udp', Blocking => '0') or die "socket: $@"; The recv call is my…
doon
  • 2,311
  • 7
  • 31
  • 52
1 2
3
44 45