शब्दकोश · नेटवर्किंग

Socket

A socket is the operating system endpoint for network communication, identified by an IP address, port and protocol, that programs read from and write to.

अपडेट: अक्टूबर 6, 2026

A socket is an endpoint of a two-way communication link, exposed by the operating system as an API. A connection is uniquely identified by the 5-tuple of protocol, source IP, source port, destination IP and destination port.

Why it matters

Every network program, from a browser to a database client, uses sockets. A server creates a listening socket on a port and accepts incoming connections, each of which gets its own socket. Limits on open sockets or file descriptors are a classic cause of "too many open files" errors and exhausted ports under heavy load.

Example

import socket
s = socket.create_connection(("example.com", 443), timeout=5)
print(s.getpeername())
s.close()

This opens a TCP socket to port 443 and prints the remote address. Failure raises a timeout or connection refused error.

Common mistakes

  • Forgetting to close sockets, which leaks descriptors until the process fails.
  • Not setting timeouts so a hung peer blocks your program forever.
  • Confusing a Unix domain socket, which is local and file based, with a network socket.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.