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
54
votes
6 answers

How to find my php-fpm.sock?

I'm running Wordpress with: Nginx + PHP-FPM + APC + W3 Total Cache + PageSpeed. After 3 days researching and configuring, I succeeded to make it work. I configured PHP-FPM to run via 127.0.0.1:9000. But now I want to configure via Socket. The…
Márcio
  • 753
  • 1
  • 6
  • 12
53
votes
5 answers

UNIX Domain sockets vs Shared Memory (Mapped File)

Can anyone tell, how slow are the UNIX domain sockets, compared to Shared Memory (or the alternative memory-mapped file)? Thanks.
SyBer
  • 5,407
  • 13
  • 55
  • 64
53
votes
3 answers

How to use socket in Python as a context manager?

It seems like it would be only natural to do something like: with socket(socket.AF_INET, socket.SOCK_DGRAM) as s: but Python doesn't implement a context manager for socket. Can I easily use it as a context manager, and if so, how?
ChaimKut
  • 2,759
  • 3
  • 38
  • 64
52
votes
3 answers

How to catch and deal with "WebSocket is already in CLOSING or CLOSED state" in Node

I've been searching for a solution to the "WebSocket is already in CLOSING or CLOSED state" error message and found this: Meteor WebSocket is already in CLOSING or CLOSED state error WebSocket is already in CLOSING or CLOSED state. Answer #1 is…
adelriosantiago
  • 7,762
  • 7
  • 38
  • 71
52
votes
4 answers

How does a socket know which network interface controller to use?

If a computer has multiple network cards, all of them connected to different networks and functioning properly, when we open a socket, how does the OS determine which NIC to use with this socket? Does the socket API allow us to explicitly specify…
user500944
52
votes
7 answers

Is TCP bidirectional or full-duplex?

Bidirectional and full-duplex are different concepts. For example the Ethernet is only half-duplex because at a specific time, only one host can send data over the wire, and it cannot send and receive data simultaneously. So when we use TCP over an…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
52
votes
4 answers

Opening a SSL socket connection in Python

I'm trying to establish a secure socket connection in Python, and i'm having a hard time with the SSL bit of it. I've found some code examples of how to establish a connection with SSL, but they all involve key files. The server i'm trying to…
Raffi
  • 1,810
  • 2
  • 16
  • 25
52
votes
2 answers

Nginx cannot find unix socket file with Unicorn (no such file or directory)

I am deploying a Rails 4 app to a Fedora 19 x64 server using Nginx and Unicorn. The problem is that I get an error when visiting the address: "We're sorry, but something went wrong." My Nginx error log (/var/log/nginx/error.log) shows: 2014/03/08…
jamsesso
  • 1,848
  • 2
  • 17
  • 20
52
votes
1 answer

Can I open a socket and pass it to another process in Linux

In Linux, is it possible for me to open a socket and pass the socket to another process? If yes, can you please tell me where I can find an example? Thank you.
n179911
  • 19,547
  • 46
  • 120
  • 162
52
votes
4 answers

Getting the IP Address of a Remote Socket Endpoint

How do I determine the remote IP Address of a connected socket? I have a RemoteEndPoint object I can access and well as its AddressFamily member. How do I utilize these to find the ip address? Thanks! Currently trying IPAddress.Parse(…
bobber205
  • 12,948
  • 27
  • 74
  • 100
52
votes
5 answers

difference between netstat and ss in linux?

In linux, netstat command tells us information of active sockets in system. I understand that netstat uses /proc/net/tcp to acquire the system network information. Since netstat man page says that netstat is obsolete, so we should use 'ss'. NOTE …
daehee
  • 5,047
  • 7
  • 44
  • 70
51
votes
8 answers

The I/O operation has been aborted because of either a thread exit or an application request

My application is working as a client application for a bank server. The application is sending a request and getting a response from the bank. This application is normally working fine, but sometimes The I/O operation has been aborted because of…
funsukvangdu
  • 1,621
  • 4
  • 20
  • 33
51
votes
3 answers

How to close a socket left open by a killed program?

I have a Python application which opens a simple TCP socket to communicate with another Python application on a separate host. Sometimes the program will either error or I will directly kill it, and in either case the socket may be left open for…
Mr. Shickadance
  • 5,283
  • 9
  • 45
  • 61
51
votes
4 answers

Sending string via socket (python)

I have two scripts, Server.py and Client.py. I have two objectives in mind: To be able to send data again and again to server from client. To be able to send data from Server to client. here is my Server.py : import socket serversocket =…
harveyslash
  • 5,906
  • 12
  • 58
  • 111
51
votes
11 answers

An attempt was made to access a socket in a way forbidden by its access permissions

I have a website on HostGator and a dedicated server of my own running SQL Server 2008R2. The connection string I use is X.X.X.X,1433 which points to the IP address of my dedicated server. I have made the firewall settings on my server so that I…
Jerry
  • 521
  • 1
  • 5
  • 7