ICT 6544 Distributed Systems Lecture 5

Size: px
Start display at page:

Download "ICT 6544 Distributed Systems Lecture 5"

Transcription

1 ICT 6544 Distributed Systems Lecture 5 Hossen Asiful Mustafa

2 Message Brokers Figure The general organization of a message broker in a message-queuing system.

3 IBM s WebSphere Message-Queuing System Figure General organization of IBM s message-queuing system.

4 Message Transfer (1) Figure The general organization of an MQ queuing network using routing tables and aliases.

5 Message Transfer (2) Figure Primitives available in the message-queuing interface.

6 Data Stream Figure A general architecture for streaming stored multimedia data over a network.

7 Streams and Quality of Service Properties for Quality of Service: The required bit rate at which data should be transported. The maximum delay until a session has been set up The maximum end-to-end delay. The maximum delay variance, or jitter. The maximum round-trip delay.

8 Enforcing QoS (1) Figure Using a buffer to reduce jitter.

9 Enforcing QoS (2) Figure The effect of packet loss in (a) non interleaved transmission and (b) interleaved transmission.

10 Synchronization Mechanisms (1) Figure The principle of explicit synchronization on the level data units.

11 Synchronization Mechanisms (2) Figure The principle of synchronization as supported by high-level interfaces.

12 UNIX Network Programming

13 Types of Internet Sockets Different types of sockets implement different communication types (stream vs. datagram) Type of socket: stream socket connection-oriented two way communication reliable (error free), in order delivery can use the Transmission Control Protocol (TCP) e.g. telnet, ssh, http Type of socket: datagram socket connectionless, does not maintain an open connection, each packet is independent can use the User Datagram Protocol (UDP) e.g. IP telephony 13

14 Network Programming Programmer should consider the following: Byte Ordering Naming Addressing 14

15 Byte Ordering of Integers Different CPU architectures have different byte ordering Stored at little-endian computer Integer representation (2 byte) Stored at big-endian computer memory address A +1 high-order byte D3 low-order byte memory address A low-order byte F2 high-order byte 15

16 Byte Ordering Problem What would happen if two computers with different integer byte ordering communicate? Nothing if they do not exchange integers! But: If they exchange integers, they would get the wrong order of bytes, therefore, the wrong value! Message is: [Hello,1] Message is: [Hello,256] Message in Memory of little-endian Computer C 4C 6F Message is sent Message in Memory of of big-endian Computer across Network C 4C 6F

17 Byte Ordering Solution There are two solutions if computers with different byte ordering system want to communicate They must know the kind of architecture of the sending computer (bad solution, it has not been implemented) Introduction of a network byte order. The functions are: uint16_t htons(uint16_t host16bitvalue) uint32_t htonl(uint32_t host32bitvalue) uint16_t ntohs(uint16_t net16bitvalue) uint32_t ntohs(uint32_t net32bitvalue) Use these function for all integers (short and long), which are sent across the network User the function for port numbers and IP addresses 17

18 Naming and Addressing Host name identifies a single host variable length string (e.g. is mapped to one or more IP addresses IP Address written as dotted octets (e.g ) 32 bits. Not a number! But often needs to be converted to a 32-bit to use. Port number identifies a process on a host 16 bit number 18

19 Client-Server Architecture response Client Server request Client requests service from server Server responds with sending service or error message to client 19

20 Simple Client-Server Example Client socket() connect() send() response request Connection establishment Data request Server socket() bind() listen() accept() recv() recv() close() Data response End-of-file notification send() recv() close() 20

21 Example: Client Programming Create stream socket (socket() ) Connect to server (connect() ) While still connected (loop): send message to server (send() ) receive (recv() ) data from server and process it Close TCP connection and Socket (close()) 21

22 socket(): Initializing Socket Getting the file descriptor int chat_sock; if ((chat_sock = socket(af_inet, SOCK_STREAM, 0)) < 0) { perror("socket"); printf("failed to create socket\n"); abort (); 1.parameter specifies protocol/address family 2.parameter specifies the socket type Other possibilities: SOCK_DGRAM 3.parameter specifies the protocol. 0 means protocol is chosen by the OS. 22

23 IP Address Data Structure struct sockaddr_in { short int sin_family; // Address family ; unsigned short int sin_port; // Port number struct in_addr sin_addr; // Internet address unsigned char sin_zero[8]; struct in_addr { ; unsigned long s_addr; // 4 bytes Padding of sin_zeros: struct sockaddr_in has same size as struct sockaddr 23

24 struct sockaddr_in sin; connect(): Making TCP Connection to Server struct hostent *host = gethostbyname (argv[1]); unsigned int server_address = *(unsigned long *) host->h_addr_list[0]; unsigned short server_port = atoi (argv[2]); memset (&sin, 0, sizeof (sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = server_address; sin.sin_port = htons (server_port); if (connect(chat_sock, (struct sockaddr *) &sin, sizeof (sin)) < 0) { perror("connect"); printf("cannot connect to server\n"); abort(); 24

25 send(): Sending Packets int send_packets(char *buffer, int buffer_len) { sent_bytes = send(chat_sock, buffer, buffer_len, 0); if (send_bytes < 0) { perror ( send"); return 0; Needs socket descriptor, Buffer containing the message, and Length of the message Can also use write() 25

26 Receiving Packets: Separating Data in a Stream Fixed length record Fixed length record A B C D receive buffer slide through Use records (data structures) to partition the data stream 26

27 Receiving Packets int receive_packets(char *buffer, int buffer_len, int *bytes_read) { int left = buffer_len - *bytes_read; received = recv(chat_sock, buffer + *bytes_read, left, 0); if (received < 0) { perror ( recv"); buffer if (received <= 0) { return close_connection(); *bytes_read += received; while (*bytes_read > RECORD_LEN) { process_packet(buffer, RECORD_LEN); *bytes_read -= RECORD_LEN; memmove(buffer, buffer + RECORD_LEN, *bytes_read); return 0; Can also use read() *bytes_read buffer_len 27

28 Server Programming: Simple Create stream socket (socket() ) Bind port to socket (bind() ) Listen for new client (listen() ) While (true){ accept user connection and create a new socket (accept() ) data arrives from client (recv() ) data has to be send to client (send() ) 28

29 bind(): Assign IP and Port struct sockaddr_in sin; struct hostent *host = gethostbyname (argv[1]); unsigned int server_address = *(unsigned long *) host->h_addr_list[0]; unsigned short server_port = atoi (argv[2]); memset (&sin, 0, sizeof (sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = server_address; sin.sin_port = htons (server_port); if (bind(chat_sock, (struct sockaddr *) &sin, sizeof (sin)) < 0) { perror("bind"); printf("cannot bind server application to network\n"); abort(); 29

30 bind(): bind() tells the OS to assign a local IP address and local port number to the socket. Many applications let the OS choose an IP address. Use wildcard INADDR_ANY as local address in this case. At server, user process must call bind() to assign a port At client, bind() is not required since OS may assign available port and IP address The server will get the port number of the client through the UDP/TCP packet header Note: Each application is represented by a server port number 30

31 listen(): Wait for Connections int listen(int sockfd, int backlog); Puts socket in a listening state, willing to handle incoming TCP connection request. Backlog: number of TCP connections that can be queued at the socket. 31

32 Server Example #define MYPORT 8081 // the port users will be connecting to #define BACKLOG 10 // how many pending connections queue will hold int main(void) { int sockfd, new_fd; // listen on sockfd, new connection on new_fd struct sockaddr_in my_addr; // my address information struct sockaddr_in their_addr; // connector's address information int sin_size; if ((sockfd = socket(af_inet, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); my_addr.sin_family = AF_INET; // host byte order my_addr.sin_port = htons(myport); // short, network byte order my_addr.sin_addr.s_addr = INADDR_ANY; // auto. filled with local IP memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct 32

33 if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) { perror("bind"); exit(1); if (listen(sockfd, BACKLOG) == -1) { perror("listen"); exit(1); while(1) { // main accept() loop sin_size = sizeof(struct sockaddr_in); if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) { perror("accept"); continue; printf("server: got connection from %s\n", inet_ntoa(their_addr.sin_addr)); if (send(new_fd, "Hello, world!\n", 14, 0) == -1) perror("send"); close(new_fd); return 0; 33

34 #include <netinet/in.h> #include <sys/socket.h> Client Example #define PORT 3490 // the port client will be connecting to #define MAXDATASIZE 100 // max number of bytes we can get // at once int main(int argc, char *argv[]) { int sockfd, numbytes; char buf[maxdatasize]; struct hostent *he; struct sockaddr_in their_addr; // server's address information if (argc!= 2) { fprintf(stderr,"usage: client hostname\n"); exit(1); if ((he=gethostbyname(argv[1])) == NULL) { // get the host info perror("gethostbyname"); exit(1); if ((sockfd = socket(af_inet, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); 34

35 their_addr.sin_family = AF_INET; // host byte order their_addr.sin_port = htons(port); // short, network byte order their_addr.sin_addr = *((struct in_addr *)he->h_addr); // already network byte order memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1){ perror("connect"); exit(1); if ((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) { perror("recv"); exit(1); buf[numbytes] = '\0'; printf("received: %s",buf); close(sockfd); return 0; 35

36 I/O Blocking socket(); bind() ; listen(); While(true){ accept(); recv() ; send() ; Simple server has blocking problem Suppose 5 connections accepted. Suppose next accept() blocks. Other connections cannot send and receive. Cannot get keyboard input either. SOCK_NONBLOCK can be used to make accept() non-blocking 36

37 select() :I/O Multiplexing waits on multiple file descriptors and timeout returns when any file descriptor is ready to be read or written or indicate an error, or timeout exceeded advantages simple application does not consume CPU cycles while waiting disadvantages does not scale to large number of file descriptors 37

38 Example: Server Programming create stream socket (socket() ) Bind port to socket (bind() ) Listen for new client (listen() ) While Wait for (select() ) (depending on which file descriptors are ready) accept user connection and create a new socket (accept() ) data arrives from client (recv() ) data has to be send to client (send() ) 38

39 Server: Alternative Ways of Handling Many Clients Forking a new process for each client: fork() But, creating new process is expensive. Multithreaded implementation: have one thread handling each client. Thread is like a process but light-weighted. 39

40 Network Programmer s Mistakes byte ordering separating records in streams use of select() misinterpreting the project specification not knowing all available system calls 40

41 There are more System Calls Depends on communication type Datagram sockets use recvfrom() and sendto() for receiving and sending data Closing connection: close(), shutdown() Convenient functions (on UNIX) inet_aton, inet_ntoa inet_pton, inet_ntop 41

42 HOMEWORK Write a simple TCP client and TCP server from the where the server reverses the client data and send back. Example: client sends hello, server replies olleh. Use linux gcc library for compiling the programs and execute (you can use a ubuntu vm) You can run the client and server in the same machine in different terminal. Run the server first and then the client.

EECS122 Communications Networks Socket Programming. Jörn Altmann

EECS122 Communications Networks Socket Programming. Jörn Altmann EECS122 Communications Networks Socket Programming Jörn Altmann Questions that will be Addressed During the Lecture What mechanisms are available for a programmer who writes network applications? How to

More information

EE 122: Sockets. Motivation. Sockets. Types of Sockets. Kevin Lai September 11, 2002

EE 122: Sockets. Motivation. Sockets. Types of Sockets. Kevin Lai September 11, 2002 Motivation EE 122: Sockets Kevin Lai September 11, 2002 Applications need Application Programming Interface (API) to use the network API: set of function types and data structures and constants Desirable

More information

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs Introduction to Unix Network Programming Reference: Stevens Unix Network Programming How do we Communicate? Send a mail from Alice to Bob Bob Alice in Champaign, Bob in Hollywood Example: US Postal Service

More information

Unix Network Programming

Unix Network Programming Introduction to Computer Networks Polly Huang EE NTU Unix Network Programming The socket struct and data handling System calls Based on Beej's Guide to Network Programming 1 The Unix Socket A file descriptor

More information

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C

Socket Programming. CSIS0234A Computer and Communication Networks. Socket Programming in C 1 CSIS0234A Computer and Communication Networks Socket Programming in C References Beej's Guide to Network Programming Official homepage: http://beej.us/guide/bgnet/ Local mirror http://www.cs.hku.hk/~c0234a/bgnet/

More information

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm

CS118 Discussion 1B, Week 1. Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm CS118 Discussion 1B, Week 1 Taqi Raza BUNCHE 1209B, Fridays 12:00pm to 1:50pm 1 TA Taqi, PhD student in Computer Networking Discussion (1B): Bunche 1209, Fri 12:00 1:50 p.m. Office hours: Boelter Hall

More information

CS321: Computer Networks Introduction to Application Layer

CS321: Computer Networks Introduction to Application Layer CS321: Computer Networks Introduction to Application Layer Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Basic Application layer provides services to the

More information

CS321: Computer Networks Socket Programming

CS321: Computer Networks Socket Programming CS321: Computer Networks Socket Programming Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Socket Programming It shows how the network application programs

More information

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

CSC209H Lecture 9. Dan Zingaro. March 11, 2015 CSC209H Lecture 9 Dan Zingaro March 11, 2015 Socket Programming (Kerrisk Ch 56, 57, 59) Pipes and signals are only useful for processes communicating on the same machine Sockets are a general interprocess

More information

Department of Computer Science

Department of Computer Science Department of Computer Science Notes on Interprocess Communication in Unix Jean Dollimore,Oct.1990, last revised Feb. 1996 These notes explain how you can write "distributed programs" in C or C++ running

More information

Why a Computer Network??? Stand alone Computer. For What?

Why a Computer Network??? Stand alone Computer. For What? Computer Network Josua M Sinambela, CCNP, CCNA, CEH, CompTIA Security+ Computer Network & Security Consultant RootBrain IT Training & Consulting Email : josh@rootbrain.com Website: www.rootbrain.com 1

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University Sockets Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Client-Server Model Most network application is based on the client-server model: A server

More information

Chapter 6. The Transport Layer. Transport Layer 3-1

Chapter 6. The Transport Layer. Transport Layer 3-1 Chapter 6 The Transport Layer Transport Layer 3-1 Transport services and protocols provide logical communication between app processes running on different hosts transport protocols run in end systems

More information

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University A Socket Example & George Mason University Everything is a file descriptor Most socket system calls operate on file descriptors Server - Quick view socket() bind() listen() accept() send(), recv() close()

More information

Socket Programming for TCP and UDP

Socket Programming for TCP and UDP CSCI4430 Data Communication and Computer Networks Socket Programming for TCP and UDP ZHANG, Mi Jan. 19, 2017 Outline Socket Programming for TCP Introduction What is TCP What is socket TCP socket programming

More information

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University  Embedded Software Lab. 1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over

More information

ECE 435 Network Engineering Lecture 2

ECE 435 Network Engineering Lecture 2 ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 6 September 2018 Announcements Homework 1 will be posted. Will be on website, will announce

More information

Socket Programming TCP UDP

Socket Programming TCP UDP Socket Programming TCP UDP Introduction Computer Network hosts, routers, communication channels Hosts run applications Routers forward information Packets: sequence of bytes contain control information

More information

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Sockets Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Internet Connections (1) Connection Clients and servers communicate by sending streams of

More information

Tutorial on Socket Programming

Tutorial on Socket Programming Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Hao Wang (Slides are mainly from Seyed Hossein Mortazavi, Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client-server

More information

Programming with TCP/IP. Ram Dantu

Programming with TCP/IP. Ram Dantu 1 Programming with TCP/IP Ram Dantu 2 Client Server Computing Although the Internet provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a

More information

ECE 435 Network Engineering Lecture 2

ECE 435 Network Engineering Lecture 2 ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 31 August 2017 Announcements Homework 1 will be posted. Will be on website, will announce

More information

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~ Sockets Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu PA #2 Reviews set_name, get_name, del_name Will

More information

Ports under 1024 are often considered special, and usually require special OS privileges to use.

Ports under 1024 are often considered special, and usually require special OS privileges to use. 1 2 Turns out that besides an IP address (used by the IP layer), there is another address that is used by TCP (stream sockets) and, coincidentally, by UDP (datagram sockets). It is the port number. It's

More information

CLIENT-SIDE PROGRAMMING

CLIENT-SIDE PROGRAMMING CLIENT-SIDE PROGRAMMING George Porter Apr 11, 2018 ATTRIBUTION These slides are released under an Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Creative Commons license These slides

More information

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013

Processes communicating. Network Communication. Sockets. Addressing processes 4/15/2013 Processes communicating Network Communication Process: program running within a host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different

More information

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups) The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1 Work Individually (no groups) Due Date: in class, Monday, September 19 Robert T Olsen olsen@cswiscedu 7390CS Office Hours: 3-5T, 11-12F - exception

More information

A Client-Server Exchange

A Client-Server Exchange Socket programming A Client-Server Exchange A server process and one or more client processes Server manages some resource. Server provides service by manipulating resource for clients. 1. Client sends

More information

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005

Lecture 7. Followup. Review. Communication Interface. Socket Communication. Client-Server Model. Socket Programming January 28, 2005 Followup symbolic link (soft link): pathname, can be across file systems, replacement of file will be active on all symbolic links, consumes at least an inode. hard link: pointers to an inode, only in

More information

UNIX Network Programming. Overview of Socket API Network Programming Basics

UNIX Network Programming. Overview of Socket API Network Programming Basics UNIX Network Programming Overview of Socket API Network Programming Basics 1 Client-Server Model Client Machine A Network Server Machine B Web browser and server FTP client and server Telnet client and

More information

CS 3516: Computer Networks

CS 3516: Computer Networks Welcome to CS 3516: Prof. Yanhua Li Time: 9:00am 9:50am M, T, R, and F Location: AK219 Fall 2018 A-term 1 Some slides are originally from the course materials of the textbook Computer Networking: A Top

More information

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software

Session NM056. Programming TCP/IP with Sockets. Geoff Bryant Process software Session NM056 Programming TCP/IP with Sockets Geoff Bryant Process software Course Roadmap Slide 57 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server

More information

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme

Socket Programming. Dr. -Ing. Abdalkarim Awad. Informatik 7 Rechnernetze und Kommunikationssysteme Socket Programming Dr. -Ing. Abdalkarim Awad Informatik 7 Rechnernetze und Kommunikationssysteme Before we start Can you find the ip address of an interface? Can you find the mac address of an interface?

More information

CS 640: Computer Networking

CS 640: Computer Networking CS 640: Computer Networking Yu-Chi Lai Lecture 3 Network Programming Topics Client-server model Sockets interface Socket primitives Example code for echoclient and echoserver Debugging With GDB Programming

More information

Lab 0. Yvan Petillot. Networks - Lab 0 1

Lab 0. Yvan Petillot. Networks - Lab 0 1 Lab 0 Yvan Petillot Networks - Lab 0 1 What You Will Do In This Lab. The purpose of this lab is to help you become familiar with the UNIX/LINUX on the lab network. This means being able to do editing,

More information

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name

More information

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket

More information

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms Interprocess Communication 1 Interprocess Communication Mechanisms ffl shared storage These mechanisms have already been covered. examples: Λ shared virtual memory Λ shared files processes must agree on

More information

Oral. Total. Dated Sign (2) (5) (3) (2)

Oral. Total. Dated Sign (2) (5) (3) (2) R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer

More information

Introduction to Socket Programming

Introduction to Socket Programming UNIT II - ELEMENTARY TCP SOCKETS Introduction to Socket Programming Introduction to Sockets Socket address Structures Byte ordering functions address conversion functions Elementary TCP Sockets socket,

More information

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar

Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar Socket Programming What is a socket? Using sockets Types (Protocols) Associated functions Styles We will look at using sockets in C Java sockets are conceptually quite similar - Advanced Data Communications:

More information

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C.

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C. Simple TCP Clients and Servers on *nix with C. Aims. This worksheet introduces a simple client and a simple server to experiment with a daytime service. It shows how telnet can be used to test the server.

More information

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018

CS 43: Computer Networks. 05: Socket Programming September 12-14, 2018 CS 43: Computer Networks 05: Socket Programming September 12-14, 2018 Reading Quiz Lecture 5/6 - Slide 2 Socket Programming Adapted from: Donahoo, Michael J., and Kenneth L. Calvert. TCP/IP sockets in

More information

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements

Hybrid of client-server and P2P. Pure P2P Architecture. App-layer Protocols. Communicating Processes. Transport Service Requirements Announcements CS 5565 Network Architecture and Protocols Lecture 5 Godmar Back Problem Set 1 due Feb 17 Project 1 handed out shortly 2 Layer The Layer Let s look at some s (in keeping with top-down) architectures:

More information

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles

SOCKET PROGRAMMING. What is a socket? Using sockets Types (Protocols) Associated functions Styles LABORATORY SOCKET PROGRAMMING What is a socket? Using sockets Types (Protocols) Associated functions Styles 2 WHAT IS A SOCKET? An interface between application and network The application creates a socket

More information

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani

sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Federico Reghenzani Titolo presentazione Piattaforme Software per la Rete sottotitolo Socket Programming Milano, XX mese 20XX A.A. 2016/17 Outline 1) Introduction to Sockets 2) UDP communication 3) TCP communication 4) RAW

More information

CS307 Operating Systems Processes

CS307 Operating Systems Processes CS307 Processes Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Process Concept Process a program in execution An operating system executes a variety of

More information

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State CS307 Process Concept Process a program in execution Processes An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks All these activities are

More information

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement

Context. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement Distributed Systems: Sockets Programming Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Context Computer Network hosts, routers, communication channels Hosts run applications

More information

VMCI Sockets Programming Guide VMware ESX/ESXi 4.x VMware Workstation 7.0 VMware Server 2.0

VMCI Sockets Programming Guide VMware ESX/ESXi 4.x VMware Workstation 7.0 VMware Server 2.0 VMware ESX/ESXi 4.x VMware Workstation 7.0 VMware Server 2.0 This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition.

More information

Network programming(i) Lenuta Alboaie

Network programming(i) Lenuta Alboaie Network programming(i) Lenuta Alboaie adria@info.uaic.ro 2017 2018 Computer Network http://www.info.uaic.ro/~computernetworks 1 Content Client/server paradigm API for network programming BSD Socket Characteristics

More information

Internet protocol stack. Internetworking II: Network programming. April 20, UDP vs TCP. Berkeley Sockets Interface.

Internet protocol stack. Internetworking II: Network programming. April 20, UDP vs TCP. Berkeley Sockets Interface. 15-213 Internetworking II: Network programming Berkeley sockets interface Internet protocol stack April 20, 2000 Topics client/server model Berkeley sockets TCP client and server examples UDP client and

More information

Network Communication

Network Communication Network Communication Processes communicating Process: program running within a host. q within same host, two processes communicate using inter- process communica6on (defined by OS). q processes in different

More information

Internetworking II: Network programming. April 20, 2000

Internetworking II: Network programming. April 20, 2000 15-213 Internetworking II: Network programming Topics April 20, 2000 client/server model Berkeley sockets TCP client and server examples UDP client and server examples I/O multiplexing with select() Internet

More information

Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel

Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel Internettechnologien (CS262) Socket Programming in C 4. März 2015 Christian Tschudin (basierend auf einem Foliensatz von C. Jelger und T. Meyer) Departement Mathematik und Informatik, Universität Basel

More information

TCP: Three-way handshake

TCP: Three-way handshake Sockets in C 1 Sockets in C The slides by themselves will not be sufficient to learn how to write socket code. If you did not attend class, then you will want to review the relevant chapters in Kerrisk

More information

CSE 333 SECTION 8. Sockets, Network Programming

CSE 333 SECTION 8. Sockets, Network Programming CSE 333 SECTION 8 Sockets, Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls Server side network programming steps and calls dig and ncat tools Network

More information

Εργαστήριο 9 I/O Multiplexing

Εργαστήριο 9 I/O Multiplexing Εργαστήριο 9 I/O Multiplexing Στοεργαστήριοθαμελετηθούν: Server High Level View I/O Multiplexing Solutions for Concurrency nonblocking I/O Use alarm and signal handler to interrupt slow system calls. Use

More information

The User Datagram Protocol

The User Datagram Protocol The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.

More information

Socket Programming 2007/03/28

Socket Programming 2007/03/28 Socket Programming 2007/03/28 Reference W. Richard Stevens, Unix Network Programming 2/e Volume 1,1998 James F. Kurose and Keith W. Ross, "Computer Networks: A Top-Down Approach Featuring the Internet

More information

CSE 124 Discussion Section Sockets Programming 10/10/17

CSE 124 Discussion Section Sockets Programming 10/10/17 CSE 124 Discussion Section Sockets Programming 10/10/17 Topics What s a socket? Creating a socket Connecting a socket Sending data Receiving data Resolving URLs to IPs Advanced socket options Live code

More information

Socket Programming(2/2)

Socket Programming(2/2) Socket Programming(2/2) 1 Outline 1. Introduction to Network Programming 2. Network Architecture Client/Server Model 3. TCP Socket Programming 4. UDP Socket Programming 5. IPv4/IPv6 Programming Migration

More information

Sockets 15H2. Inshik Song

Sockets 15H2. Inshik Song Sockets 15H2 Inshik Song Internet CAU www server (www.cau.ac.kr) Your web browser (Internet Explorer/Safari) Sockets 2 How do we find the server? Every computer on the Internet has an Internet address.

More information

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.

UNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)

More information

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy Network Programming Samuli Sorvakko/Nixu Oy Telecommunications software and Multimedia Laboratory T-110.4100 Computer Networks October 16, 2008 Agenda 1 Introduction and Overview Introduction 2 Socket

More information

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition ELEC / COMP 177 Fall 2014 Some slides from Kurose and Ross, Computer Networking, 5 th Edition Project #1 Starts in one week Is your Linux environment all ready? Bring your laptop Work time after quick

More information

SOCKETS. COMP750 Distributed Systems

SOCKETS. COMP750 Distributed Systems SOCKETS COMP750 Distributed Systems Sockets The Socket library is a traditional Application Program Interface (API) to the transport layer. Sockets were originally implemented in Unix systems and have

More information

CompSci 356: Computer Network Architectures Lecture 3: Hardware and physical links References: Chap 1.4, 1.5 of [PD] Xiaowei Yang

CompSci 356: Computer Network Architectures Lecture 3: Hardware and physical links References: Chap 1.4, 1.5 of [PD] Xiaowei Yang CompSci 356: Computer Network Architectures Lecture 3: Hardware and physical links References: Chap 1.4, 1.5 of [PD] Xiaowei Yang xwy@cs.duke.edu Overview Lab overview Application Programming Interface

More information

Elementary TCP Sockets

Elementary TCP Sockets Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Distributed Computer Systems 1 socket interface Application 1 Application 2 socket interface user kernel user kernel

More information

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services. 15-213 The course that gives CMU its Zip! Network programming Nov 27, 2001 Topics Client- model Sockets interface Echo and Client- model Every network application is based on the - model: Application is

More information

Piotr Mielecki Ph. D.

Piotr Mielecki Ph. D. Piotr Mielecki Ph. D. http://mielecki.ristel.pl/ piotr.mielecki@pwr.edu.pl pmielecki@gmail.com Building blocks of client-server applications: Client, Server, Middleware. Simple client-server application:

More information

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron

MSc Integrated Electronics Networks Assignment. Investigation of TCP/IP Sockets and Ports. Gavin Cameron MSc Integrated Electronics Networks Assignment Investigation of TCP/IP Sockets and Ports Gavin Cameron Introduction TCP and IP (Transmission Control Protocol / Internet Protocol) are two protocols from

More information

Introduction and Overview Socket Programming Lower-level stuff Higher-level interfaces Security. Network Programming. Samuli Sorvakko/Nixu Oy

Introduction and Overview Socket Programming Lower-level stuff Higher-level interfaces Security. Network Programming. Samuli Sorvakko/Nixu Oy Network Programming Samuli Sorvakko/Nixu Oy Telecommunications software and Multimedia Laboratory T-110.4100 Computer Networks October 5, 2009 Agenda 1 Introduction and Overview 2 Socket Programming 3

More information

Application Programming Interfaces

Application Programming Interfaces Application Programming Interfaces Stefan D. Bruda Winter 2018 SYSTEM CALLS Machine 1 Machine 2 Application 1 Application 3 Application 4 Application 5 Application 2 API (system functions) API (system

More information

Client software design

Client software design Client software design Stefan D. Bruda Winter 2018 A TCP CLIENT 1 Get the IP address and port number of the peer 2 Allocate a socket 3 Choose a local IP address 4 Allow TCP to choose an arbitrary, unused

More information

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy

Introduction and Overview Socket Programming Higher-level interfaces Final thoughts. Network Programming. Samuli Sorvakko/Nixu Oy Network Programming Samuli Sorvakko/Nixu Oy Telecommunications software and Multimedia Laboratory T-110.4100 Computer Networks October 9, 2006 Agenda 1 Introduction and Overview Introduction 2 Socket Programming

More information

Network Socket Programming - 3 BUPT/QMUL

Network Socket Programming - 3 BUPT/QMUL Network Socket Programming - 3 BUPT/QMUL 2018-04-02 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface

More information

Network Programming and Protocl Design. Nixu Ltd.

Network Programming and Protocl Design. Nixu Ltd. Network Programming and Protocl Design Nixu Ltd. What is a socket? Sockets (also known as Berkeley Sockets) is an application programming interface (API) to the operating system s TCP/IP stack Used on

More information

Network Socket Programming - 3 BUPT/QMUL

Network Socket Programming - 3 BUPT/QMUL Network Socket Programming - 3 BUPT/QMUL 2017-3-27 Agenda Basic concepts in NP Introduction to IP & TCP/UDP Introduction to Sockets 2 Introduction to Sockets Reviews of some helpful points Sockets interface

More information

CompSci 356: Computer Network Architectures. Lecture 3: Network Architecture Examples and Lab 1. Xiaowei Yang

CompSci 356: Computer Network Architectures. Lecture 3: Network Architecture Examples and Lab 1. Xiaowei Yang CompSci 356: Computer Network Architectures Lecture 3: Network Architecture Examples and Lab 1 Xiaowei Yang xwy@cs.duke.edu Overview The Internet Architecture OSI Network Architecture Lab 1 Released Due:

More information

UNIX Sockets. COS 461 Precept 1

UNIX Sockets. COS 461 Precept 1 UNIX Sockets COS 461 Precept 1 Socket and Process Communica;on application layer User Process Socket transport layer (TCP/UDP) OS network stack network layer (IP) link layer (e.g. ethernet) Internet Internet

More information

Applications and Layered Architectures. Chapter 2 Communication Networks Leon-Garcia, Widjaja

Applications and Layered Architectures. Chapter 2 Communication Networks Leon-Garcia, Widjaja Applications and Layered Architectures Chapter 2 Communication Networks Leon-Garcia, Widjaja Network Architecture Architecture: Any design or orderly arrangement perceived by man. The goals of a network:

More information

Introduction to Socket Programming

Introduction to Socket Programming Introduction to Socket Programming (Advanced Computer Networks) By Priyank Shah NET ID : pss160530 A Simple Question What are Sockets? Sockets are communication points on the same or different computers

More information

CSc 450/550 Computer Networks Network Architectures & Client-Server Model

CSc 450/550 Computer Networks Network Architectures & Client-Server Model CSc 450/550 Computer Networks Network Architectures & Client-Server Model Jianping Pan Summer 2007 5/17/07 CSc 450/550 1 Last lectures So far, nuts and bolts views of the Internet Internet evolution and

More information

CSE 333 Lecture 16 - network programming intro

CSE 333 Lecture 16 - network programming intro CSE 333 Lecture 16 - network programming intro Hal Perkins Department of Computer Science & Engineering University of Washington Today Network programming - dive into the Berkeley / POSIX sockets API -

More information

9/13/2007. Motivations for Sockets What s in a Socket? Working g with Sockets Concurrent Network Applications Software Engineering for Project 1

9/13/2007. Motivations for Sockets What s in a Socket? Working g with Sockets Concurrent Network Applications Software Engineering for Project 1 Daniel Spangenberger 15 441 Computer Networks, Fall 2007 Goal of Networking: Communication Share data Pass Messages Say I want to talk to a friend in Singapore How can I do this? What applications and

More information

TCP/IP Sockets in C: Practical Guide for Programmers. Computer Chat. Internet Protocol (IP) IP Address. Transport Protocols. Ports

TCP/IP Sockets in C: Practical Guide for Programmers. Computer Chat. Internet Protocol (IP) IP Address. Transport Protocols. Ports TCP/IP Sockets in C: Practical Guide for Programmers Computer Chat! How do we make computers talk? Michael J. Donahoo Kenneth L. Calvert Morgan Kaufmann Publisher $14.95 Paperback! How are they interconnected?

More information

Beej s Guide to Network Programming

Beej s Guide to Network Programming Using Internet Sockets Brian "Beej" Hall beej@piratehaven.org Revision History Copyright 1995-2001 by Brian "Beej" Hall Revision Version 1.0.0 August, 1995 Revised by: beej Initial version. Revision Version

More information

System Programming. Sockets

System Programming. Sockets Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introducing 2 3 Internet

More information

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS Communication Distributed Systems Fall 2002 Communication Process Process Networks and protocols Sockets Remote Invocation Messages Streams 9/10/2001 DoCS 2002 2 Layered Protocols (1) Layers, interfaces,

More information

Internet applications

Internet applications CSc 450/550 Computer Networks Worldwide Web Jianping Pan Summer 2006 5/18/06 CSc 450/550 1 Traditionally Internet applications remote login: e.g., telnet file transfer: e.g., FTP electronic mail: e.g.,

More information

Distributed Information Processing

Distributed Information Processing Distributed Information Processing 6 th Lecture Eom, Hyeonsang ( 엄현상 ) Department of Computer Science & Engineering Seoul National University Copyrights 2016 Eom, Hyeonsang All Rights Reserved Outline

More information

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics

WinSock. What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics WinSock What Is Sockets What Is Windows Sockets What Are Its Benefits Architecture of Windows Sockets Network Application Mechanics What Is Sockets Standard API (Application Programming Interface) for

More information

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.

Outline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer. Outline Distributed Computer Systems Socket basics Socket details (TCP and UDP) Socket options Final notes Sockets Socket Basics An end-point for a IP network connection what the application layer plugs

More information

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University  Embedded Software Lab. 1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Echo Client (1) 2 #include #include #include #include

More information

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS

Outline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS Outline Operating Systems Socket basics Socket details Socket options Final notes Project 3 Sockets Socket Basics An end-point for a IP network connection what the application layer plugs into programmer

More information

Communication. Sockets (Haviland Ch. 10)

Communication. Sockets (Haviland Ch. 10) Communication Sockets (Haviland Ch. 10) 1 Simple Web Request 5LFKDUG V+RPH3DJH &RXUVHV 5HVHDUFK 2 How do we find the server? Every computer on the Internet has an Internet address. Called an IP address

More information

Beej s Guide to Network Programming Using Internet Sockets

Beej s Guide to Network Programming Using Internet Sockets Beej s Guide to Network Programming Using Internet Sockets Brian Beej Hall beej@beej.us Version 2.3.12 September 23, 2005 Copyright 2005 Brian Beej Jorgensen Hall Beej s Guide to Network Programming Using

More information

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction!

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction! Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction! This Lecture! Elementary TCP sockets! TCP Client-Server example! Source: Stevens book(chapters 4,5), Comer s book (Chapters 20, 21)!

More information

Network Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions

Network Programming in C: The Berkeley Sockets API. Networked Systems 3 Laboratory Sessions Network Programming in C: The Berkeley Sockets API Networked Systems 3 Laboratory Sessions The Berkeley Sockets API Widely used low-level C networking API First introduced in 4.3BSD Unix Now available

More information