1 Ch 3. Network Programming. 2 Network Programming (1)  Network allows arbitrary applications to communicate E.g., client-server computing such as WEB.

Slides:



Advertisements
Similar presentations
Computer Net Lab/Praktikum Datenverarbeitung 2 1 Overview Sockets Sockets in C Sockets in Delphi.
Advertisements

CSE 333 – SECTION 8 Networking and sockets. Overview Network Sockets IP addresses and IP address structures in C/C++ DNS – Resolving DNS names Demos.
CSC383 Computer Networks Dr. Allen M. Johnson, Jr.
Socket Programming Application Programming Interface.
COEN 445 Communication Networks and Protocols Lab 4
Alogrithm Analysis 實踐資管 Wang-Jiunn Cheng 2004 PART II Signals, Media, and Data Transmission.
Elementary TCP Sockets Computer Networks Computer Networks Term B10 UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
Socket Programming.
1 Creating a network app Write programs that  run on different end systems and  communicate over a network.  e.g., Web: Web server software communicates.
CSCI 4550/8556 Computer Networks Comer, Chapter 3: Network Programming and Applications.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
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.
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L22 (Chapter 25) Networking.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
ISP – 9 th Recitation Socket programming – Client side.
1 Socket Programming A crash-course in network programming…
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
I NTRODUCTION OF S OCKET P ROGRAMMING L.Aseel AlTurki King Saud University.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Elementary UDP Sockets© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer.
Socket programming in C. Socket programming Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm.
1 Computer Networks DA Chapter 1-3 Introduction.
LWIP TCP/IP Stack 김백규.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
CS4273: Distributed System Technologies and Programming I Lecture 7: Java Networking.
Introduction to Network Programming Asst. Prof. Chaiporn Jaikaeo, Ph.D. Computer Engineering Department.
Sun RPC also called ONC (Open Network Computing) RPC originally designed for client-server communication for Sun Network File System (NFS) provides an.
Vassil Roussev 2 A socket is the basic remote communication abstraction provided by the OS to processes. controlled by operating system.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
---- IT Acumens. COM IT Acumens. COMIT Acumens. COM.
Chapter 2 Applications and Layered Architectures Sockets.
Remote Shell CS230 Project #4 Assigned : Due date :
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Networking COMP # 22.
TFTP: Trivial file transfer protocol
Socket Programming Lec 2 Rishi Kant. Review of Socket programming Decide which type of socket – stream or datagram. Based on type create socket using.
1 COMP445 Fall 2006 Lab assignment 1. 2 STEP1: Get the name of the second party STEP2: Get phone number from white pages CALLERRECEIVER STEP1: Plug the.
1 Computer Networks An Introduction to Computer Networks University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani Lecture 3: Sockets.
CSE/EE 461 Getting Started with Networking. 2 Basic Concepts A PROCESS is an executing program somewhere. –Eg, “./a.out” A MESSAGE contains information.
Socket Programming Tutorial Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Computer Networks & PROTOCOLS (CSI 4118) FALL 2005 Professor Robert L. Probert.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Sockets Socket = abstraction of the port concept: –Application programs request that the operating system create a socket when one is needed –O.S. returns.
Client/Server Socket Programming Project
Socket Programming.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
S OCKET P ROGRAMMING IN C Professor: Dr. Shu-Ching Chen TA: HsinYu Ha.
Berkeley Socket Abstraction
CSCI 330 UNIX and Network Programming Unit XIV: User Datagram Protocol.
1 Computer Networks and Internets. 2 Internet Growth.
Mandatory Assignment INF3190. Part 1: Client-server communication via TCP Develop a client-server application in C which allows a client to send UNIX.
A Local Area Network Chat Client ITTC LAN CHAT John Vincent Cecogo Jerikho Daguno Ardee Santos Elaine Mendoza Anjomar Pat Del Mindo Philip John Sales Philip.
Socket Programming in C CS587x Lecture 3 Department of Computer Science Iowa State University.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
SOCKET PROGRAMMING Presented By : Divya Sharma.
Sockets and Beginning Network Programming
Sockets and Beginning Network Programming
CS 1652 Jack Lange University of Pittsburgh
Elementary UDP Sockets
Networks and Client/Server Applications
CSI 4118 – UNIVERSITY OF OTTAWA
Chapter 3 Socket API © Bobby Hoggard, Department of Computer Science, East Carolina University These slides may not be used or duplicated without permission.
Socket Programming Neil Tang 09/08/2008
Computer Networks DA2402.
Presentation transcript:

1 Ch 3. Network Programming

2 Network Programming (1)  Network allows arbitrary applications to communicate E.g., client-server computing such as WEB browsing  GUI  Functions supported  data transmission via underlying network

3 Network Programming (2)  A programmer can create Internet application software without understanding the underlying network technology  Network facilities are accessed through an Application Program Interface (API)

4

5

6 Echo server  Useful for network testing  Server returns exact copy of data sent  Server: Bind port number  Client: Assign server IP (host) and port number (AP) LAN ServerClient > echoserver > echoclient X 22000

7

8 A Intuitive Look at the API Server await_contact() recv() send() send_eof() Client make_contact() send() recv() send_eof()

9 Exercise: Files needed  CNAI API code readln.c send_eof.c make_contact.c cname_to_comp.c cnaiapi_init.c await_contact.c appname_to_appnum.c  Header files cnaiapi.h cnaiapi_win32.h  C source code echoserver.c echoclient.c  Readme.txt

10 Build net programs under Windows (1)  Have cnaiapi.lib available [File][New][Win32 Static Library] Replace #include with #include “xxx.h“ in.c and.h files [Project][Add to project][Fies]  Seven.c files [Build][Build cnaiapi.lib]

11 Build net programs under Windows (2)  Include “cnaiapi.h” in each of the C program files that use CNAI API library calls  Link cnaiapi.lib into the program [project] [settings] [Link tag] [general category] including 'cnaiapi.lib‘ in the Object/Library Modules setting the Additional Library Path in the Input Cate.  link to the WinSock 2 library (ws2_32.lib)

12 Appendix

13

14 A Intuitive Look at the API ServerClient socket() // open a TCP socket bind() listen() accept() read() write() connect() // bind port number assign server IP and port number // connect to the specific // server write() read() // blocking mode closes ()close ()

15

16 A Intuitive Look at the API Server await_contact() recv() send() send_eof() Client make_contact() send() recv() send_eof()

17 Echo client  /* echoclient.c */  #include  #define BUFFSIZE256  #define INPUT_PROMPT"Input > "  #define RECEIVED_PROMPT"Received> "  int readln(char *, int);  /*  *  * Program: echoclient  * Purpose: contact echoserver, send user input and print server response  * Usage: echoclient [appnum]  * Note: Appnum is optional. If not specified the standard echo appnum  * (7) is used.  *  *  */  int  main(int argc, char *argv[])  {  computercomp;  appnumapp;  connectionconn;  charbuff[BUFFSIZE];  intexpect, received, len;  if (argc 3) {  (void) fprintf(stderr, "usage: %s [appnum]\n",  argv[0]);  exit(1);  }

18  /* convert the arguments to binary format comp and appnum */  comp = cname_to_comp(argv[1]);  if (comp == -1)  exit(1);  if (argc == 3)  app = (appnum) atoi(argv[2]);  else  if ((app = appname_to_appnum("echo")) == -1)  exit(1);   /* form a connection with the echoserver */  conn = make_contact(comp, app);  if (conn < 0)  exit(1);  (void) printf(INPUT_PROMPT);  (void) fflush(stdout);

19  /* iterate: read input from the user, send to the server,*/  /* receive reply from the server, and display for user */  while((len = readln(buff, BUFFSIZE)) > 0) {  /* send the input to the echoserver */  (void) send(conn, buff, len, 0);  (void) printf(RECEIVED_PROMPT);  (void) fflush(stdout);  /* read and print same no. of bytes from echo server */  expect = len;  for (received = 0; received < expect;) {  len = recv(conn, buff, (expect - received) < BUFFSIZE ?  (expect - received) : BUFFSIZE, 0);  if (len < 0) {  send_eof(conn);  return 1;  }  (void) write(STDOUT_FILENO, buff, len);  received += len;  }  (void) printf("\n");  (void) printf(INPUT_PROMPT);  (void) fflush(stdout);  }  /* iteration ends when EOF found on stdin */  (void) send_eof(conn);  (void) printf("\n");  return 0;  }

20

21 A Intuitive Look at the API Server await_contact() recv() send() send_eof() Client make_contact() send() recv() send_eof()