Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Could someone explain to me what a socket is? I see it in many acronyms in context of SSL, etc.

Also, why is it called a socket? Is it purely because it was what a name they invented? Or was it the first name they came up with?

share|improve this question

2 Answers 2

up vote 14 down vote accepted

A socket is just a logical endpoint for communication. They exist on the transport layer. You can send and receive things on a socket, you can bind and listen to a socket. A socket is specific to a protocol, machine, and port, and is addressed as such in the header of a packet.

Beej's guides to Network Programming and Inter-Process Communication both have good information on how to use sockets, and even answer this exact question.

share|improve this answer

A socket an abstraction. It provides a interface for applications to utilize a system resource (in this case the network connection) in a way that allows the operating system to mediate and organize the use of a limited resource by any number of applications.

If the data being sent through the socket could be thought of as envelopes of mail, then the socket would be your mail box. You attach a mailbox(socket) to your house(program) and put your outgoing mail(data) into it. At a scheduled time the mailman (operating system) comes along and picks up your outgoing mail and drops off any incoming mail in the same mailbox. Your outgoing mail is conveyed on your behalf to the recipient through the mailman's truck(network connection) along with all your neighbors' mail. This allows you to correspond with people far away without the need for the expense, time, difficulty, etc. of delivering the letter yourself.

As for why they're called 'sockets' well, the notion that the inventors get to call it whatever they want probably plays a large role there. Though, it's not a bad name in my opinion :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.