Questions tagged [recvfrom]

The recvfrom() call is used to receive messages from a socket, and may be used to receive data on a socket whether or not it is connection-oriented.

The recvfrom() call is used to receive messages from a , and may be used to receive data on a socket whether or not it is connection-oriented.

Synopsis

#include <sys/types.h>
#include <sys/socket.h>

ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen);

Description

sockfd   -- the socket file descriptor to read from  
buf      -- The pointer to the memory location where the data has to be stored   
len      -- The length of the data to be read  
flags    -- Various flags to modify the socket file descriptor  
src_addr -- The memory location where the source address of the message will be filled  
addrlen  -- addrlen is a value-result argument, which the caller should initialize 
before the call to the size of the buffer associated with src_addr, and modified on
return to indicate the actual size of the source address.

Return Value

recvfrom() return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutdown.

Errors

There are some standard errors generated by the socket layer. Additional errors may be generated and returned from the underlying protocol modules. For the complete list, see the manual pages.

126 questions
0
votes
0 answers

UDP not receiving second time

I don't understand that much about network connections. I have followed a lot of example code and it works the first time, but not the second and it makes no sense why. The "server side" is a PC running Ubuntu 16.04. The "client side" is running…
drmike
  • 1
0
votes
1 answer

recvfrom for storing in 2D Char array

trying to collect 1261 UDP packet in 2D Char array using recvfrom function define RxBuffSize 1514 define TotalPacket 1261 char RxBuff[RxBuffSize] = {0}; and the code i am trying to use is: for (Count =0; Count <= TotalPacket;…
0
votes
1 answer

Why tcp raw socket hangs on recvfrom?

I have implemented this code to communicate with my device from pc. It get a several packets then it hangs on recvfrom() in while loop ? import socket, sys, random from struct import * import struct import select import codecs import base64 import…
user1886376
0
votes
1 answer

Stuck in a timeout loop from using alarm();

I'm attempting to implement a GoBackN protocol and when the server drops a packet, my alarm waits 2 seconds before sending all previously sent packets. The alarm works and waits 2 seconds, however after the first timeout, the state machine I'm using…
Austin Heath
  • 75
  • 1
  • 3
  • 9
0
votes
0 answers

Python recvfrom buffer too slow

I am using a precoded script since I am a Python noob and run into some trouble concerning socket programming. I use two computers, one is running a Matlab/Simulink real time application, which is sending data via UDP to my windows laptop. The data…
Gilian
  • 1
0
votes
1 answer

recvfrom function in C on Windows skips UDP data when using MinGW

I have problem with recvfrom function on Windows I cannot resolve. See the following part of code I wrote. I run this code on Linux and Windows and I get different results in udp bitrate value. When compiling it on Windows using Cygwin, I get the…
Przemo
  • 193
  • 2
  • 16
0
votes
1 answer

recvfrom() is returning size of buffer instead of number of bytes read

In prep for my first time coding UDP, I'm trying out some example client and server code copied and lightly modified from here. Everything seems to be working except that the value returned by recvfrom() is always the size of the buffer instead of…
GISmatters
  • 431
  • 8
  • 20
0
votes
1 answer

How to check the python socket recvfrom() data

I am working on socket programming in python. Using ESP python i have created a socket to server and sending a request (in API packet format, according to server code it will respond). In receiving socket, i need to check the data(if data is…
varma v
  • 1
  • 1
  • 3
0
votes
1 answer

Performance of recvfrom on iPhone/iOS

I'm working on an app with which speed is absolutely crucial. We use a UDP connection over a dedicated wifi (no public internet, same room wifi). In general a wifi connection should be able to deliver a 512byte package within less than 1ms. For some…
0
votes
1 answer

why sendto cost much more than recvfrom

I wrote a very simple program that one PC doing udp sendto, and another PC doing recvfrom. On 1Gbps ethernet link, the sender side cost 13% CPU but the receiver side cost only 5%. Anyone know why sendto cost so much higher than recvfrom,and any good…
Patrick
  • 51
  • 1
  • 2
  • 6
0
votes
0 answers

recvfrom() Timeout c programming

I have problem with setting timeout to recvfrom(). I run my code under Cygwin64 environment. .his is a sample from my code: if(( clientSock=socket(AF_INET, SOCK_DGRAM,0))==-1){ // creat client socket perror("Socket Initialisation…
SHADOW.NET
  • 555
  • 1
  • 5
  • 20
0
votes
1 answer

How do I cause a message to be dropped after 1 second? (UDP client/server in C)

I have a UDP client based off of http://cs.baylor.edu/~donahoo/practical/CSockets/code/UDPEchoClient.c where the client sends a message and the server echos it back. I have a configurable server where I can drop packets, and I am sending multiple…
ThePumpkinMaster
  • 2,181
  • 5
  • 22
  • 31
0
votes
1 answer

Get buffer from recvfrom

I'm trying to write tic-tack-toe game communicates through UDP. For now I have code: int recv_txt(int sock, struct sockaddr_in *incoming_addr) { char bud[MAX_LENGTH]; unsigned int incoming_add_len; incoming_add_len =…
Sk1X1
  • 1,305
  • 5
  • 22
  • 50
0
votes
0 answers

recvfrom not working on client side

I'm making a low level peer to peer application, when a peer needs to know what file is with what peer, it asks the tracker/server(which is maintaining a register). The tracker then replies with the address of that peer. In my program, the tracker…
Adnan Khan
  • 387
  • 2
  • 12
0
votes
2 answers

UDP recvfrom warning with gcc compiler

I am receiving the following warning when compiling my client - server UDP socket simulation: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign…
Brian
  • 7,098
  • 15
  • 56
  • 73
1 2 3
8 9