BSD Sockets function used for receiving data from a TCP socket.
Questions tagged [recv]
670 questions
10
votes
2 answers
c recv() read until newline occurs
I'm working on writing a IRC bot in C, and have ran into a snag.
In my main function, I create my socket and connect, all that happy stuff. Then I have a (almost) infinite loop to read what's being sent back from the server. I then pass what's read…

FurryHead
- 1,479
- 3
- 16
- 19
10
votes
5 answers
Socket programming: recv/read issue
EDIT: the code below has been fixed to receive and send properly AND to account for the actual bytes of messages sent annd recieved (latter thanks to EJP)
I'm programming with C in Unix.
I have server and client that are supposed to exchange msgs.…

Fantastic Fourier
- 613
- 7
- 13
- 20
9
votes
4 answers
Unblock recvfrom when socket is closed
Let's say I start a thread to receive on a port. The socket call will block on recvfrom.
Then, somehow in another thread, I close the socket.
On Windows, this will unblock recvfrom and my thread execution will terminate.
On Linux, this does not…

user657178
- 213
- 1
- 3
- 7
9
votes
3 answers
Multiple calls to send() are merged into one call to recv()
I have a client-server application.
The client is sending a string followed by an integer using two distinct send() calls. These two data are supposed to be stored into two different variables on the server.
The problem is that both variables sent…

geraldCelente
- 1,005
- 2
- 16
- 36
9
votes
3 answers
C++ How can I send an object via socket?
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;
…

rosekarma
- 117
- 1
- 1
- 12
9
votes
2 answers
Raw Socket Linux send/receive a packet
Have some problems in receiving packets.
I can receive and read incoming packets, but I think i do not get a handshake with any host.
I only want to send a packet to a remote computer with an open port on receiving an answer to see the TTL(time to…

x4k3p
- 1,598
- 2
- 22
- 42
9
votes
1 answer
gen_tcp receive extremely high CPU
Sorry that I'm an Erlang newbie and may make stupid question. But please help me to solve the issue.
I have written an Erlang server to replace the one I'm using with Node.js, which ate all my memory and I'm praying that Erlang could be a way…

Anita
- 119
- 5
8
votes
2 answers
Read signaled by select(), but recv() returns no data and signal EAGAIN on non-blocking sockets
I have got signaled socket for read from select(), but then no data arrived by recv call(), instead it returns -1 with errno==EAGAIN.
I can grant that no other thread touch the socket.
I think that this behavior is not correct. If an subsequent…

Zdenal
- 81
- 1
- 2
8
votes
3 answers
Can a C socket recv 0 bytes without the client shutting the connection?
I've implemented a web server in C. It calls recv() on a connected, blocking socket to receive an incoming HTTP request. The Linux man pages state the following about recv() on a blocking socket:
If no messages are available at the socket, the…

dmoon1221
- 287
- 1
- 3
- 9
8
votes
2 answers
is it safe to recv() and send() on one socket concurrently?
I remember having read somewhere that a socket can be regarded as two independent half-duplex channels. Does it mean that recv() and send() of the same socket are actually irrelevant?
if so, is it by definition or
implementation-specific?
if…

t.g.
- 1,719
- 2
- 14
- 25
8
votes
3 answers
Do recv() and send() convert the messages in network order format automatically?
I am very new in socket programming. I found that before sending messages we have to convert host byte order into network byte order. I have taken a look on many examples given on various sites but nobody have changed there messages into network…

Nishant
- 267
- 3
- 11
8
votes
3 answers
JeroMQ shutdown correctly
I am wondering how to shutdown JeroMQ properly, so far I know three methods that all have their pro and cons and I have no clue which one is the best.
The situation:
Thread A: owns context, shall provide start/stop methods
Thread B: actual listener…

Sebastian Schlicht
- 347
- 2
- 15
7
votes
2 answers
Is there a way to know how much data is available in a Python socket to receive?
I have figured out that I must use ioctl. There are similar questions here:
How to tell how much data is in a Socket's send buffer
Determing the number of bytes ready to be recv()'d
My questions are:
What is an equivalent to FIONREAD in Python?…

utapyngo
- 6,946
- 3
- 44
- 65
7
votes
3 answers
Download HTTP thru sockets (C)
Recently I started taking this guide to get myself started on downloading files from the internet. I read it and came up with the following code to download the HTTP body of a website. The only problem is, it's not working. The code stops when…

v1Axvw
- 3,054
- 3
- 26
- 40
7
votes
1 answer
Python Socket - Send/Receive messages at the same time
Basically I have been working on a simple chat room using socket and thread. In my client I can receive and send messages, my issue is that one comes before another in a loop, so if I am sending a message I will only receive data once I have sent a…

Satyrs
- 85
- 1
- 1
- 7