Fall 2000Datacom 11 Socket Programming Review Examples: Client and Server-Diagnostics UDP versus TCP Echo.

Slides:



Advertisements
Similar presentations
Socket Programming Application Programming Interface.
Advertisements

Networks: TCP/IP Socket Calls1 Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens.
EECS122 Communications Networks Socket Programming January 30th, 2003 Jörn Altmann.
Tutorial 8 Socket Programming
CS 311 – Lecture 18 Outline IPC via Sockets – Server side socket() bind() accept() listen() – Client side connect() Lecture 181CS Operating Systems.
Socket Addresses. Domains Internet domains –familiar with these Unix domains –for processes communicating on the same hosts –not sure of widespread use.
CSE/EE 461 Getting Started with Networking. Basic Concepts  A PROCESS is an executing program somewhere.  Eg, “./a.out”  A MESSAGE contains information.
1 Socket Programming A crash-course in network programming…
Sockets COS 518: Advanced Computer Systems Michael Freedman Fall
UNIX Sockets COS 461 Precept 1. Clients and Servers Client program – Running on end host – Requests service – E.g., Web browser Server program – Running.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
Cs423-cotter1 Example Client Program Reference Comer & Stevens, Chapter 7.
Computer Networks Chapter 1: Foundation
Basic Socket Programming TCP/IP overview. TCP interface Reference: –UNIX Network Programming, by Richard Stevens. –UNIX man page.
1 Programming with TCP/IP Ram Dantu. 2 Client Server Computing r Although the Internet provides a basic communication service, the protocol software cannot.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
CS1652 September 13th, 2012 The slides are adapted from the publisher’s material All material copyright J.F Kurose and K.W. Ross, All Rights.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Communication. References Chapter 3, Tanenbaum and Van Steen Beej’s Network Programming Guide.
Network Programming Tutorial #9 CPSC 261. A socket is one end of a virtual communication channel Provides network connectivity to any other socket anywhere.
Fall 2000Datacom 11 Lecture 4 Socket Interface Programming: Service Interface between Applications and TCP.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
1 Chapter 1 Foundation Computer Networks: A Systems Approach, 5e Larry L. Peterson and Bruce S. Davie Copyright © 2010, Elsevier Inc. All rights Reserved.
The Application Layer Application Services (Telnet, FTP, , WWW) Reliable Stream Transport (TCP) Connectionless Packet Delivery Service (IP) Unreliable.
 Wind River Systems, Inc Chapter - 13 Network Programming.
Remote Shell CS230 Project #4 Assigned : Due date :
1 Example Servers Pt 1 Objective: To discuss key aspects of various server implementations.
Socket Programming Lec 2 Rishi Kant. Review of Socket programming Decide which type of socket – stream or datagram. Based on type create socket using.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
TELE202 Lecture 15 Socket programming 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »TCP/UDP (2) »Source: chapter 17 ¥This Lecture »Socket programming.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
Socket Programming Lab 1 1CS Computer Networks.
Sockets Socket = abstraction of the port concept: –Application programs request that the operating system create a socket when one is needed –O.S. returns.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
Chapter 2 Applications and Layered Architectures Sockets.
2: Application Layer1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
Introduction to Sockets
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Review: – Why layer architecture? – peer entities – Protocol and service interface – Connection-oriented/connectionless service – Reliable/unreliable service.
Read() recv() connection establishment Server (connection-oriented protocol) blocks until connection from client Client socket() bind() listen() accept()
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
UNIX Sockets Outline UNIX sockets CS 640.
1 Spring Semester 2008, Dept. of Computer Science, Technion Internet Networking recitation #7 Socket Programming.
Socket programming in C. Socket programming with TCP Client must contact server server process must first be running server must have created socket (door)
Socket Programming in C CS587x Lecture 3 Department of Computer Science Iowa State University.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
1 Vehicle Networking Networks Instruction 1 – Echo client/server in C Jeroen Voeten ES, 2012.
Sockets API Developing Applications using the Sockets API.
Sockets and Beginning Network Programming
Sockets and Beginning Network Programming
CS 1652 Jack Lange University of Pittsburgh
The Pocket Guide to TCP/IP Sockets: C Version
Socket Programming in C
Transport layer API: Socket Programming
UNIX Sockets Outline Homework #1 posted by end of day
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Internet and Intranet Protocols and Applications
The University of Adelaide, School of Computer Science
Socket Programming in C
TCP Sockets Programming
Socket Programming Neil Tang 09/08/2008
CSI 4118 – UNIVERSITY OF OTTAWA
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Presentation transcript:

Fall 2000Datacom 11 Socket Programming Review Examples: Client and Server-Diagnostics UDP versus TCP Echo

Fall 2000Datacom 12 Socket Interface-an Application Programming Interface (API) Create the Socket for a specific transport layer protocol s=socket(PF_INET,SOCK_STREAM,0) or s=socket(PF_INET,SOCK_DGRAM,0) returned value is a “handle” e.g. 3,4 etc. PF_INET: SOCK_STREAM means TCP: 1 client/server SOCK_DGRAM means UDP: multi-clients/server

Fall 2000Datacom 13 Data structures: hostent *hp hp->h_name (character) contains host name hp->h_length number of bytes in IP address hp->h_addr[4] contains IP address byte1:byte2:byte3:byte4 A.B.C.D 0<A,B,C,D< is address of localhost or loop-back address

Fall 2000Datacom 14 Data structures: sockaddr_in sin sin.sin_family AF_INET sin.sin_addr.s_addr IP address in reverse byte order DCBA is address of localhost or loop-back address sin.sin_port Server port number in some strange format

Fall 2000Datacom 15 Socket Interface: Server (a) Creating socket s=socket(PF_INET,SOCK_STREAM,0) Binding a Socket to a Port Number—this is the local address of this application bind (s, (struct sockaddr*)&sin, sizeof(sin)) The entry for IP address in sin.sin_addr.s_addr will be the client’s IP address—it cannot be specified until connection is accepted.

Fall 2000Datacom 16 Socket Interface: Server (b) Defining the queue length for the receiving socket int listen(s, MAX_PENDING) –Specify max number of calls waiting Passive listening new_s= accept (s, (struct sockaddr*)&sin,&len) –Sender’s IP address is returned as sin.sin_addr.s_addr –New socket is created and its number is returned

Fall 2000Datacom 17 Socket Interface: Server (c) Receiving a message recv(new_s, buf, sizeof(buf),0) –Receive message, store in buf Closing new socket close(new_s)

Fall 2000Datacom 18 Socket Interface: Client (a) Create a socket s=socket(PF_INET,SOCK_STREAM,0) Connecting to a server-active open connect (s, (struct sockaddr*) &sin, sizeof(sin)) Server’s IP address is stored in sin.sin_addr.s_addr Server’s Port is stored in sin.sin_port Returns accept or not accepted

Fall 2000Datacom 19 Socket Interface: Client (b) Sending message to a server send(s, buf, len, 0) –buf is a pointer to the message –len is length of message string