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
1
vote
1 answer

recvfrom() not receiving any data - python

I'm writing a simple program to get the number of hops from my machine to an arbitrary site (in this case, www.google.com. My program seems to get stuck on the recvfrom() call. I've set it to be a non-blocking socket, so I'm able to see the…
Haley
  • 77
  • 1
  • 12
1
vote
2 answers

Why does recvfrom create additional IP header?

Why does recvfrom create additional IP header? I am sending: ------------- - IP header - ------------- - Data - ------------- But when I try to receive data, it looks like there is ------------- - IP header - ------------- - IP header…
camabeh
  • 1,122
  • 12
  • 13
1
vote
1 answer

Python Socket: WinError 10022

Some years ago, I programmed a chat with Python 3 und everything worked fine on Windows and Mac, till now. This function is executed in another script: import socket import pickle def get(sock): data, addr = sock.recvfrom(1024) data =…
Hustensaft
  • 117
  • 3
  • 10
1
vote
1 answer

stop recvfrom() after certain time

I wanna wait for a constant amount of time(like 3 seconds) for recvfrom() to receive some data, and I wanna exit my program if it didn't receive anything (in this 3 seconds) how do that ?
1
vote
0 answers

recvfrom read the same frame multiple times

im playing around with STP packets and writing a program raw sockets to modify them. Reading fropm eth0 sending to eth1. System is ubuntu 14.10/ Kernel 3.somewhat. Packets are generated with additional computers with Karat and Wireshark is running…
bernie
  • 11
  • 2
1
vote
1 answer

UdpSocket.recv_from fails with "end of file" but I can see the incoming package in Wireshark

Editor's note: This code example is from a version of Rust prior to 1.0 and is not valid Rust 1.0 code. The concepts discussed in the question are still valid. I'm experimenting with torrent scraping using Rust. I can see the incoming package in…
sinan
  • 6,809
  • 6
  • 38
  • 67
1
vote
1 answer

recvfrom in socket programming with C

So I was trying to understand socket programming in C when I came across this code: /* Sample UDP client */ #include #include #include #include #include int main(int argc,…
HZero
  • 69
  • 1
  • 1
  • 7
1
vote
0 answers

Android - constactly receiving segmentation fault on recvfrom()

for my final project in BScEE i'm trying to create an ad-hoc network. I'm working on Galaxy S2 devices and writing most of my code in C ( JNI ). Except for sending normal message, i'm also automatically sending broadcasts every 5 seconds. There is a…
1
vote
1 answer

Can't listen on multiple sockets when using BINDTODEVICE?

I have two network links to the Internet, and I have two default routes set up: Destination Gateway Genmask Flags Metric Ref Use Iface default gateway0 0.0.0.0 UG 0 0 eth0 default …
erjiang
  • 44,417
  • 10
  • 64
  • 100
0
votes
0 answers

How to receive from two UDP clients concurrently using multi-threaded UDP server in python?

I am trying to implement UDP concurrent server (multi-threaded) which can accept new client and communicate with old client simultaneously. I have a main python program (called server) which creates a thread for every new accepted client and then…
0
votes
0 answers

Undertstanding UDP broadcast sending and receiving in C (system functions)

I'm trying to learn how sockets and networks work. For example in C in Linux. I have two simple programs. Both take ip and port as parameters. The first program is a server that broadcasts a message every second. int main(int argc, char** argv){ …
0
votes
1 answer

UDS Dgram \ UDP sockets while(1) in server

I Want to measure how much time takes for each socket to transfer 100MB data file so I implement many of sockets type like TCP, some pipe's mmaps etc.. The process to measure is (on the client side )::= before I send the data I take time and after…
ATB
  • 119
  • 1
  • 9
0
votes
1 answer

Signal interrupt sendto/recvfrom on datagram socket

What happens if signal interrupts sendto or recvfrom call on datagram socket? Can I expect that these calls always return -1 with errno == EINTR or they can return positive number of bytes, but I shall repeat the call entirely?
0
votes
0 answers

sendto() for UDP server is not sending data to client

I'm lost, but the title sums it up. I'm trying to make a UDP server using netster, but for whatever reason, I'll get data from the client but not the other way around. I suspect it has something to do with clientaddr due to getting an error "sendto:…
0
votes
0 answers

Python decrypting data of recvfrom

I'm currently building a sort of sniffer for a video game(Albion Online). I used the recvfrom method and I get something like that…
4mg1n3
  • 1
  • 1
1 2 3
8 9