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
2
votes
2 answers

Berkley sockets shutdown function, how important?

as background I've got an embedded device that talks to a third party server over IP. The code in the third party server is unlikely to change. In a recent release I changed the ip disconnect function to call shutdown() before calling close()…
Patrick
  • 8,175
  • 7
  • 56
  • 72
1
vote
2 answers

Reading from a socket until certain character is in buffer

I am trying to read from a socket into a buffer until a certain character is reached using read(fd, buf, BUFFLEN). For example, the socket will receive two lots of information separated by a blank line in one read call. Is it possible to put the…
DMcB1888
  • 171
  • 1
  • 3
  • 10
1
vote
0 answers

What is the normal behaviour of connect() if no server is listen()ing at the other end, or the destination machine is unreachable?

This is a question about Berkeley sockets. Normally, a client would connect to a server by calling the connect() function, and a connection would be established assuming the target machine was reachable and an application on the target machine had…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
1
vote
3 answers

How to find local/epheremal port number?

I have a UDP client program that uses Berkley sockets and Winsock (depending on the platform). Basically it uses getaddrinfo(), then socket(), then sendto(). sendto() takes the address info returned by getaddrinfo(). My code looks like this: struct…
mark
  • 11
  • 3
1
vote
1 answer

difference between "address in use" with bind() in Windows and on Linux - errno=98

I have a small TCP server that listens on a port. While debugging it's common for me to CTRL-C the server in order to kill the process. On Windows I'm able to restart the service quickly and the socket can be rebound. On Linux I have to wait a few…
stuck
  • 2,264
  • 2
  • 28
  • 62
1
vote
1 answer

Disable socket timeout, via setsockopt()

Say I have the following code in C++ that will set the time out for a socket: struct timeval time_val_struct = { 0 }; time_val_struct.tv_sec = 1; time_val_struct.tv_usec = 0; return_value = setsockopt(this->m_fdSocket, SOL_SOCKET, SO_RCVTIMEO,(const…
A. Smoliak
  • 438
  • 2
  • 17
1
vote
1 answer

How can I determine when the network stack is ready to open socket to same host/port again?

I have the following C program whose main function runTCPConnectivityCheck opens a TCP socket, sends a string of bytes to it and closes it: #include #include #include #include #include…
Richard Cook
  • 32,523
  • 5
  • 46
  • 71
1
vote
1 answer

C++ connect() in UNIX-socket based client program does not establish a connection to the server

I have written a simple socket server in c++ in CentOS 7.0 using the famous Berkeley socket interface. I run it, on whatever port, and it waits for the connections. I then run my simple client program also written with c++ and send a request…
Mostafa Talebi
  • 8,825
  • 16
  • 61
  • 105
1
vote
1 answer

ftp client on linux '500 '': command not understood. '

i try to make simple ftp client to get list of files on bsd sockets. Here it is: connectTo(int client_socket, struct sockaddr_in* addr, char* ipv4Address, char* user, char* password, …
1
vote
2 answers

TCP connection accepted, but writing data causes it to use a stale connection

The server (192.168.1.5:3001), is running Linux 3.2, and is designed to only accept one connection at a time. The client (192.168.1.18), is running Windows 7. The connection is a wireless connection. Both programs are written in C++. It works great…
Jetski S-type
  • 1,138
  • 2
  • 16
  • 32
1
vote
2 answers

How to test Berkley socket (BSD) API?

I'd like to test the correctness and the completeness of an implementation of the BSP API. The test set has to be cross-compiled for an ARM sam7x.
gsempe
  • 5,371
  • 2
  • 25
  • 29
0
votes
1 answer

Tcp socket read always blocks

I have a client TCP socket that writes a few bytes every five seconds, the server echoes the bytes right back. Connect() and write() work just fine, and I have a callback at the IP layer that notifies me of the server's echo. This reliably happens…
mr_dude
  • 107
  • 1
  • 8
0
votes
0 answers

TCP sockets: string sent by Client can't be analyzed correctly by Server in if-query

In a simple TCP server written in C, I have a function that reads a string from a client, and then checks in a if-query if it matches "GET /index.html HTTP/1.0\r\n". However, when a Client sends exactly this string from a terminal, the query always…
Kinematikk
  • 15
  • 4
0
votes
1 answer

Preprocessor check for availability of Winsockets / BSD sockets

I'm new to socket programming and want to make a cross platform app (C++) that supports both windows and unix systems. The default on for websocket transport on Windows seems to be windows sockets while on unix systems it's BSD sockets. So how can I…
glades
  • 3,778
  • 1
  • 12
  • 34
0
votes
0 answers

Simple Java Server Application deployed on Heroku, can't listen to incoming connections on specified port

I am creating a very simple Server using Java's Socket API, and have deployed it to Heroku. I've hardcoded the value of the port at which the server will listen for incoming connections. My app is deployed perfectly fine, and from the logs I can see…
Aayush Anand
  • 25
  • 1
  • 6