1 / 4

Inter-process communication: Socket

Inter-process communication: Socket. http://en.wikipedia.org/wiki/Internet_socket. Internet socket From Wikipedia, the free encyclopedia Jump to: navigation , search

virgo
Download Presentation

Inter-process communication: Socket

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Inter-process communication: Socket

  2. http://en.wikipedia.org/wiki/Internet_socket • Internet socket • From Wikipedia, the free encyclopedia • Jump to: navigation, search • In computer networking, an Internet socket or network socket is an endpoint of a bidirectional inter-processcommunication flow across an Internet Protocol-based computer network, such as the Internet. • The term Internet sockets is also used as a name for an application programming interface (API) for the TCP/IP protocol stack, usually provided by the operating system. Internet sockets constitute a mechanism for delivering incoming data packets to the appropriate application process or thread, based on a combination of local and remote IP addresses and port numbers. Each socket is mapped by the operational system to a communicating application process or thread. • A 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 between a phone number and a particular extension line at that location. • An Internet socket is characterized by a unique combination of the following: • Protocol: A transport protocol (e.g., TCP, UDP), raw IP, or others. TCP port 53 and UDP port 53 are different, distinct sockets. • Local socket address: Local IP address and port number • Remote socket address: Only for established TCP sockets. As discussed in the Client-Server section below, this is necessary since a TCP server may serve several clients concurrently. The server creates one socket for each client, and these sockets share the same local socket address. • Within the operating system and the application that created a socket, the socket is referred to by a unique integer number called socket identifier or socket number. The operating system forwards the payload of incoming IP packets to the corresponding application by extracting the socket address information from the IP and transport protocol headers and stripping the headers from the application data. • In IETFRequest for Comments, Internet Standards, in many textbooks, as well as in this article, the term socket refers to an entity that is uniquely identified by the socket number. In other textbooks[1], the socket term refers to a local socket address, i.e. a "combination of an IP address and a port number". In the original definition of socket given in RFC 147, as it was related to the ARPA network in 1971, "the socket is specified as a 32 bit number with even sockets identifying receiving sockets and odd sockets identifying sending sockets." Today, however, socket communications are bidirectional. • On Unix-like and Microsoft Windows based operating systems the netstat command line tool may be used to list all currently established sockets and related information.

  3. http://www.troubleshooters.com/codecorn/sockets/ • Sockets are interfaces that can "plug into" each other over a network. Once so "plugged in", the programs so connected communicate. This article discusses only simple aspects of stream inet sockets (don't worry about exactly what that is right now). For the purposes of this article, a "server" program is exposed via a socket connected to a certain /etc/services port number. A "client" program can then connect its own socket to the server's socket, at which time the client program's writes to the socket are read as stdin to the server program, and stdout from the server program are read from the client's socket reads. This is one subset of socket programming, but it's perhaps the easiest to master, so this is where you should start. • Diagram of client-server socket connection via xinetd.  Note that the client communicates by reading and writing the socket, but the server program communicates via stdin and stdout. This tutorial requires a Linux box. It hasn't been tested on other types of UNIX, but I think it might work. This tutorial is centered around a system using xinetd, but it would be simple enough to adapt it to older inetd systems. This tutorial will not work under Windows. I think it's important that this complex type of programming be learned on the most reliable, straightforward system possible, so Windows is out. • For the purposes of this tutorial, the server application will be at port 3333. Note that you can implement both the client and the server on a single computer, in which case the client is connected to a port on the computer containing both the client and the server. So if you have only one Linux box you can still do this tutorial.

  4. Host B (server) Host A (client) socket bind listen accept(blocks) t1 socket connect (blocks) SYN, Seq_no = x t2 SYN, Seq_no = y, ACK, Ack_no = x+1 connect returns t3 Seq_no = x+1, ACK, Ack_no = y+1 write read (blocks) accept returns read (blocks) t4 t5 Request message read returns t6 write read (blocks) Reply message read returns Client-Server Application

More Related