Questions tagged [sockets]

An endpoint of a bi-directional inter-process communication flow. This often refers to a process flow over a network connection, but by no means is limited to such. Not to be confused with WebSocket (a protocol) or other abstractions (e.g. socket.io).

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.

An internet 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. It is primarily used in the Transport Layer.

An example IPv4 socket appears as: 10.1.1.1:80

An example IPv6 socket appears as: [fe80::1]:80 (Note the brackets)

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

Related tags are , , , and .

* Not to be confused with (a protocol) or other abstractions (e.g. ).

Note to programmers, especially beginners, using the socket module: A great many questions about non-working socket programs seem to be based on a common misunderstanding that is discussed and corrected in this answer as well as this one. Please take the time to read and understand that answer if you are having problems.

66255 questions
57
votes
16 answers

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

I've just recently moved my websites from apache2 to Nginx as my new web server backend. got to love problems aha. HTML files in the web host director work prior to php files making there way main directory then I received 502 error from nginx Error…
Michel Barrette
  • 591
  • 1
  • 4
  • 4
57
votes
6 answers

Can I use Socket.IO with Django?

Is there any way to use Socket.IO http://socket.io/ with Django?
User
  • 1,363
  • 2
  • 13
  • 23
57
votes
4 answers

Cross-platform sockets

I know, Windows doesn't use UNIX sockets while Mac OS does. Until this point my software was cross-platform without any code changes. But now I want it to do some network communication. I know about POSIX sockets, but I know nothing about Windows'…
ForceBru
  • 43,482
  • 10
  • 63
  • 98
57
votes
2 answers

How does zmq poller work?

I am confused as to what poller actually does in zmq. The zguide goes into it minimally, and only describes it as a way to read from multiple sockets. This is not a satisfying answer for me because it does not explain how to have timeout sockets. I…
user1876508
  • 12,864
  • 21
  • 68
  • 105
56
votes
2 answers

Do Java sockets support full duplex?

Is it possible to have one thread write to the OutputStream of a Java Socket, while another reads from the socket's InputStream, without the threads having to synchronize on the socket?
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
56
votes
2 answers

Python simple socket client/server using asyncio

I would like to re-implement my code using asyncio coroutines instead of multi-threading. server.py def handle_client(client): request = None while request != 'quit': request = client.recv(255).decode('utf8') response =…
srjjio
  • 930
  • 1
  • 8
  • 16
56
votes
8 answers

Java simple code: java.net.SocketException: Unexpected end of file from server

I wrote some simple code in Java, the method should connect to the website and return the BufferedReader. private BufferedReader getConnection(String url_a) { URL url; try { System.out.println("getting connection"); …
Maciej Skrzypiński
  • 557
  • 1
  • 4
  • 10
56
votes
6 answers

Server Client send/receive simple text

I have a homework to build an application which will send and receive simple string between server and client. I know how to establish connection, but don't know how to send and receive string. This is my code : public partial class Form1 : Form { …
Iposify
  • 663
  • 2
  • 7
  • 9
55
votes
5 answers

Blocking sockets: when, exactly, does "send()" return?

When, exactly, does the BSD socket send() function return to the caller? In non-blocking mode, it should return immediately, correct? As for blocking mode, the man page says: When the message does not fit into the send buffer of the socket,…
David Citron
  • 43,219
  • 21
  • 62
  • 72
55
votes
2 answers

Node.js request module getting ETIMEDOUT and ESOCKETTIMEDOUT

I'm crawling a lot of links with the request module in parallel with combination of the async module. I'm noticing alot of ETIMEDOUT and ESOCKETTIMEDOUT errors although the links are reachable and respond fairly quickly using chrome. I've limit the…
Jorayen
  • 1,737
  • 2
  • 21
  • 52
55
votes
5 answers

PostgreSQL UNIX domain sockets vs TCP sockets

I wonder if the UNIX domain socket connections with postgresql are faster then tcp connections from localhost in high concurrency rate and if it does, by how much?
user20955
  • 2,552
  • 4
  • 24
  • 23
55
votes
3 answers

UDP multicast group on Windows Phone 8

OK this is one I've been trying to figure out for a few days now. We have an application on Windows Phone 7 where phones join a multicast group and then send and receive messages to the group to talk to each other. Note - this is phone to phone…
Adam Stewart
  • 1,983
  • 1
  • 18
  • 25
55
votes
4 answers

Send HTTP request manually via socket

When I send a normal HTTP request via a socket, the server does not respond with an OK response. I copied the HTTP header from Firefox. Here is the code: Socket s = new Socket(InetAddress.getByName("stackoverflow.com"), 80); PrintWriter pw = new…
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
54
votes
5 answers

What are SO_SNDBUF and SO_RCVBUF

Can you explain me what exactly are SO_SNDBUF and SO_RCVBUF options? OK, for some reason the OS buffers the outgoing/incomming data but I'd like to clarify this subject. What is their role (generally)? Are they per-socket buffers? Is there a…
Hex
  • 621
  • 1
  • 6
  • 6
54
votes
5 answers

WSACancelBlockingCall exception

Ok, I have a strange exception thrown from my code that's been bothering me for ages. System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall at System.Net.Sockets.Socket.Accept() at…
Radu094
  • 28,068
  • 16
  • 63
  • 80