Questions tagged [berkeley-sockets]

The Berkeley sockets API comprises a library for developing applications in the C programming language that perform inter-process communication, most commonly for communications across a computer network.

In computer networking, a socket is an endpoint of a bidirectional inter-process communication flow across an Internet Protocol-based computer network, such as the Internet.

A socket address is the combination of an IP address (the location of the computer) and a port (which is mapped to the application program process) into a single identity, much like one end of a telephone connection is the combination of a phone number and a particular extension.

The term is believed to have originated with the Berkeley Sockets API for Unix ca. 1983.

67 questions
0
votes
1 answer

recvfrom non-blocking returning BAD ADDRESS error in c++

I'm getting a "BAD ADDRESS" error when trying to listen and not when sending. Sending works perfectly with sendto(). Here's the function that creates the socket to listen. IP and Port are local (this is intented to execute in the same local network,…
Darkgaze
  • 2,280
  • 6
  • 36
  • 59
0
votes
1 answer

How long are UDP datagrams stored in a socket?

I'm in openSUSE Linux (v15.1), using berkeley sockets. I have a "sender" app that sends a datagram each second. Another "receiver" app that reads all the time. It works well. But If I have both turned off, send some datagrams from the sender, turn…
Darkgaze
  • 2,280
  • 6
  • 36
  • 59
0
votes
0 answers

What is the relation of the 'domain' parameter of the 'socket' function with the "data link" layer?

I am reading UNIX® Network Programming Volume 1, Third Edition: The Sockets Networking API, and on page 1.7 OSI Model, the authors introduce the "OSI model" and the equivalent "Internet protocol suite". Looking at the man page for socket(2), I…
canellas
  • 491
  • 5
  • 17
0
votes
2 answers

Using thread notification with Berkeley sockets

I am utilizing the Berkeley sockets select function in the following way. /*Windows and linux typedefs/aliases/includes are made here with wsa junk already taken care of.*/ /**Check if a socket can receive data without waiting. \param socket The…
Cygnuson
  • 160
  • 1
  • 11
0
votes
1 answer

Linux c++ recvfrom() changes (destroys) the [socket] file descriptor

I have written a simple UDP server. Well, naturally I use recvfrom() function somewhere in it. I have searched the net for it, and found that it is caused by the buffer overflow. Is this true? But I can't figure why my code fails and throws the same…
Mostafa Talebi
  • 8,825
  • 16
  • 61
  • 105
0
votes
1 answer

Are EHOSTDOWN and EHOSTUNREACH fatal in connect()?

How to respond to these errors when they happen in connect() (non-blocking)? I want to know whether I should kill this socket and create a new one, or I can wait some time and try again with existing socket and all will work (if remote host became…
Nokeya
  • 3
  • 5
0
votes
1 answer

In iOS, why doesn't socket recv fail when the underlying network changes?

In iOS when I've got a blocking socket with a timeout set using SO_RCVTIMEO. When I change the WiFi network that the device is connected to, the calls to recv will timeout appropriately, but errno will be reported as EWOULDBLOCK and recv returns…
Joey Carson
  • 2,973
  • 7
  • 36
  • 60
0
votes
0 answers

Berkley Sockets and read timeout

My system is C++ on ARM running Ubuntu. I am having some problems with Berkley Sockets when I am trying to do a blocking read I get an error and the code is EAGAIN. I put a timer in the code and I find that the error is occurring before the socket…
user846566
  • 373
  • 1
  • 3
  • 12
0
votes
2 answers

Berkeley Socket : recv system call

//server side void* s2(void *arg){ info *s = (info*)arg; char buffer[MAXS]; int k; sockaddr_in addr; socklen_t aSize = sizeof(sockaddr_in); int sfd = accept(s->fd,(sockaddr*)&addr,(socklen_t*)&aSize); if(sfd<0){ …
sonus21
  • 5,178
  • 2
  • 23
  • 48
0
votes
1 answer

C++ I/O Multiplexed server closes connections prematurely

i wrote a basic network programming set of C++ classes (there's nothing more than a tcp_socket a udp_socket and an ip_address wrap class class). I'm having some troubles with a I/O multiplexed server. Let me explain: The scenario is in a way like…
fitzbutz
  • 956
  • 15
  • 33
0
votes
1 answer

Berkeley sockets' passivesock portbase meaning

I am tried to understand the passive socket by tracing the code http://merkez.ube.ege.edu.tr/~erciyes/ube528/passivesock.c And I found that the following code /* Map service name to port number */ if(pse = getservbyname(service, protocol)){ …
Jason
  • 1,573
  • 3
  • 18
  • 46
0
votes
1 answer

IRC program not printing last message

I had a function that would receive data from an IRC server in 512-byte chunks and print it to the terminal window, it went like this: int mainLoop(redchan_t *redchan) { int socketDescriptor = redchan->socketDescriptor, i, bytesReceived; …
Red
  • 435
  • 1
  • 5
  • 13
0
votes
1 answer

Generation of unique IP-port using bind(0)

I need to generate port numbers for some programm. Google tells, that bind with zero-port generates binds unused port. I want to bind zero-port, remember it's number, close port. Trying to do this? but netstat doesn't see my programm's port. Linux…
red_cap
  • 3
  • 1
0
votes
1 answer

Query on schema implementation in Berkeley DB

I found below parameters which our code is using, amidst schema implementation phase. We are just using the default values as shown below. enum { CACHE_SIZE_KBYTES = 10000, LOG_SIZE_KBYTES =…
overexchange
  • 15,768
  • 30
  • 152
  • 347
0
votes
2 answers

Segmentation Fault when converting IP address to text form

I am trying to convert the IP address of any client that connect to my server to a text form as following: struct sockaddr_in *client_addr = NULL; socklen_t addrlen = sizeof(struct sockaddr_in); char client_ip[INET_ADDRSTRLEN]; …
IoT
  • 607
  • 1
  • 11
  • 23