Presentation is loading. Please wait.

Presentation is loading. Please wait.

Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.

Similar presentations


Presentation on theme: "Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over."— Presentation transcript:

1 Socket Programming Introduction

2 Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over a network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to. Sockets are created and used with a set of programming requests or "function calls" sometimes called the sockets application programming interface (API). The most common sockets API is the Berkeley UNIX C interface for sockets. Sockets can also be used for communication between processes within the same computer.

3 Socket Definition (Cont) An endpoint is a combination of an IP address and a port number. Every TCP connection can be uniquely identified by its two endpoints. That way you can have multiple connections between your host and the server.

4 Socket Types A socket is created  address domain specified  socket type specified Two processes communicate iff same sockets type and same domain. Adress Domains: – Unix domain: Processes share a common file system. The address is a character string which is basically an entry in the file system. – Internet domain: Each process has its own address format. The address is the host machine (IP address, port number). Port numbers are 16 bit unsigned integers. The lower numbers are reserved in Unix for standard services

5 Socket Types PortService 1TCP port service multiplexer 7Echo server 21FTP server 23Telnet server 80HTTP server

6 Socket Types Socket types : – stream sockets: treat communications as a continuous stream of characters use TCP (Transmission Control Protocol), which is a reliable. stream oriented protocol. – datagram sockets: read entire messages at once. use UDP (Unix Datagram Protocol). which is unreliable. message oriented.

7 Socket Programming TCPSocket = socket(PF_INET, SOCK_STREAM, 0) send() recv() UDPSocket = socket(PF_INET, SOCK_DGRAM, 0) sendto() recvfrom()


Download ppt "Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over."

Similar presentations


Ads by Google