Internet, Networking, & Security Home Networking 60 60 people found this article helpful A Brief Guide to Socket Programming for TCP/IP Computer Networks Socket programming connects server and client computers by Bradley Mitchell Writer An MIT graduate who brings years of technical experience to articles on SEO, computers, and wireless networking. our editorial process LinkedIn Bradley Mitchell Updated on February 28, 2020 Tweet Share Email Yagi Studio / Getty Images Home Networking The Wireless Connection Routers & Firewalls Network Hubs ISP Broadband Ethernet Installing & Upgrading Wi-Fi & Wireless Sockets programming is the fundamental technology behind communications on TCP/IP networks. A socket is one endpoint of a two-way link between two programs running on a network. The socket provides a bidirectional communication endpoint to send and receive data with another socket. Socket connections normally run between two different computers on a local area network (LAN) or across the internet, but they can also be used for interprocess communication on a single computer. Sockets and Addresses Socket endpoints on TCP/IP networks each have a unique address that is the combination of an IP address and a TCP/IP port number. Because the socket is bound to a specific port number, the TCP layer can identify the application that should receive the data sent to it. When creating a new socket, the socket library automatically generates a unique port number on that device. The programmer can also specify port numbers in specific situations. Micrium.com How Server Sockets Work Typically, a server runs on one computer and accesses a socket that is bound to a specific port. The server waits for a different computer to make a connection request. The client computer knows the hostname of the server computer and the port number on which the server is listening. The client computer identifies itself, and — if everything goes right — the server permits the client computer to connect. Socket Libraries Rather than code directly to low level socket APIs, network programmers typically use socket libraries. Two commonly used socket libraries are Berkeley Sockets for Linux/Unix systems and WinSock for Windows systems. A socket library provides a set of API functions similar to those programmers use for working with files, such as open(), read(), write(), and close(). Was this page helpful? Thanks for letting us know! Get the Latest Tech News Delivered Every Day Email Address Sign up There was an error. Please try again. You're in! Thanks for signing up. There was an error. Please try again. Thank you for signing up. Tell us why! Other Not enough details Hard to understand Submit