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
11
votes
3 answers

c# stream received all data?

I'm using C#.Net and the Socket class from the System.Net.Sockets namespace. I'm using the asynchronous receive methods. I understand this can be more easily done with something like a web service; this question is borne out of my curiosity rather…
user47589
11
votes
3 answers

Passive and active sockets

Quoting from this socket tutorial: Sockets come in two primary flavors. An active socket is con­nect­ed to a remote active socket via an open data con­nec­tion... A passive socket is not con­nect­ed, but rather awaits an in­com­ing…
aslı
  • 8,740
  • 10
  • 59
  • 80
11
votes
3 answers

Extending socket.socket with a new attribute

I wish to extend Python socket.socket with a new attribute (in particular, a queue.Queue, but could be anything else). I am trying to decide whether I should use inheritance or composition, but at some point both pose a problem I am not sure how to…
zeycus
  • 860
  • 1
  • 8
  • 20
11
votes
8 answers

'WinError 10013' running Django on Windows

It has been almost a month since I got this problem, and I really appreciate your help. While trying to login in my Django Web App, i encounter OSError at /accounts/login/.I am able to login in 127.0.0.1:8000/admin, but not in the /accounts/login…
Kaleab Woldemariam
  • 2,567
  • 4
  • 22
  • 43
11
votes
2 answers

How should I close a socket in a signal handler?

I'm writing a very simple server that loops forever until Ctrl-C is pressed. I'd like to have the signal handler for ctrl-c close the open sockets and shut down the server, but I don't know what the scope is for a signal handler, and I don't like…
Zxaos
  • 7,791
  • 12
  • 47
  • 61
11
votes
4 answers

Stop accepting new TCP connections without dropping any existing ones

I have two servers listening on a TCP port behind a load balancer. The load balancer can detect if a TCP connection attempt from a client was unsuccessful and retry it to the second server without dropping that connection. I want to be able to bring…
John29
  • 3,340
  • 3
  • 32
  • 50
11
votes
1 answer

UDP communication using c++ boost asio

I need to communicate with a different device in a private network over UDP. I am new to using boost, but based on what I searched online and also the tutorials on Boost website, I came up with below code.. I am currently trying to send and receive…
yath
  • 355
  • 1
  • 4
  • 14
11
votes
5 answers

Python Socket Flush

I am trying to make sure that every time I call the socket.send function my buffer is sent (flushed) to my server (which is in C using unix socket). From my understanding (and from what I see on this board) just disabling the naggle algo. should do…
Bob McLaury
  • 409
  • 1
  • 5
  • 6
11
votes
3 answers

Question about listening and backlog for sockets

I am writing an application in C# that needs to handle incoming connections and I've never done server side programming before. This leads me to these following questions: Pros and cons of high backlog / low backlog? Why shouldn't we set the…
Marlon
  • 19,924
  • 12
  • 70
  • 101
11
votes
2 answers

Why use redis for websocket communication?

Please help me clear up some confusion. Laravel allows communication with socket.io by having you set up redis: https://laravel.com/docs/5.4/broadcasting#configuration To my understanding Redis simply holds the data in memory something similar to…
Stephan-v
  • 19,255
  • 31
  • 115
  • 201
11
votes
2 answers

How read HTTP response through sockets?

I'm trying create http proxy server on android device. When i trying read response from HTTP server (example1.com) ( example1.com contains content-length in header) If HTTP server contains content-length, then i'm read bytes from content-length else…
Petr
  • 224
  • 2
  • 16
11
votes
1 answer

Linux kernel UDP reception timestamp

I've been reading the network timestamping documentation of linux kernel and there is something that it's not clear to me. Where is the timestamp provided by SO_TIMESTAMPNS generated? In hardware or in the kernel? If so it is gerated as soon as an…
Maverik
  • 2,358
  • 6
  • 34
  • 44
11
votes
2 answers

Node.js: Send GET request via unix socket

I am new to the node.js. I am trying to setup the client server connection using unix socket, where my client request would be in node.js and server running in the background would be in go. Client side Code: var request = require('request'); …
Nikita Kodkani
  • 165
  • 1
  • 2
  • 11
11
votes
2 answers

Why can Linux accept sockets in multiprocessing?

This code works fine on Linux, but fails under Windows (which is expected). I know that the multiprocessing module uses fork() to spawn a new process and the file descriptors owned by the parent (i.e. the opened socket) are therefore inherited by…
Goodies
  • 4,439
  • 3
  • 31
  • 57
11
votes
7 answers

Python ConnectionRefusedError: [Errno 61] Connection refused

Ive seen similar questions but they I couldn't fix this error. Me and my friend are making a chat program but we keep getting the error ConnectionRefusedError: [Errno 61] Connection refused We are on different networks by the way. Here is my…
Stan Theo Hettinga
  • 119
  • 1
  • 1
  • 3