3

I am studying os concepts and I found socket as the end point of communication. Now what exactly is a socket? Is it a process through means of which a system communicates? Thanks in advance

4
  • 1
    Did you read e.g. en.wikipedia.org/wiki/Network_socket? Commented Feb 21, 2015 at 17:11
  • I have read. It says "Inter Process Communication Flow".Does this mean it is a process? If so how each process gets its IP? Commented Feb 21, 2015 at 17:18
  • 1
    Your question boils down to 'teach me about networking and sockets'. It's WAY too broad. Commented Feb 21, 2015 at 21:45
  • Each device get ip by dhcp protocol or hardcode by administrator. Commented Jul 14 at 11:20

2 Answers 2

4

From reading the Wikipedia article, I can see why you may be confused.

A socket is a virtual device. That is, it is a device that is written in software and has no physical device. Thus, you can read to and write from a socket, like you would do to a terminal.

Sockets work in pairs to communicate and are usually bidirectional. One reads to socket (A) and writes to socket (B) --- or ---- writes to socket (A) and reads from socket --- or --- switches back and forth.

Generally sockets are used for network communications. They can usually support multiple protocols (TPC/IP, UDP/IP, even DECnet--the gamut depends upon the underlying system).

Sockets can be used for interprocess communication on a single system as well.

Sign up to request clarification or add additional context in comments.

Comments

1

Most of the c-family languages and their based languages implement socket as Berkeley sockets which are implemented as file descriptors. From Wikipedia:

In the traditional implementation of Unix, file descriptors index into a per-process file descriptor table maintained by the kernel, that in turn indexes into a system-wide table of files opened by all processes, called the file table. This table records the mode with which the file (or other resource) has been opened: for reading, writing, appending, and possibly other modes. It also indexes into a third table called the inode table that describes the actual underlying files.[3] To perform input or output, the process passes the file descriptor to the kernel through a system call, and the kernel will access the file on behalf of the process. The process does not have direct access to the file or inode tables.

So on a high-level, sockets are implemented as files whose file-descriptors or handles are referenced as identifier to the socket.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.