Networking in Java. Java Fundamentals. Dmitri Gabbasov Tartu 2016
|
|
- Myles Thomas
- 6 years ago
- Views:
Transcription
1 Networking in Java Java Fundamentals Dmitri Gabbasov Tartu 2016
2 The java.net package java.net.socket represents a TCP connection to a remote endpoint java.net.serversocket represents a TCP endpoint that others can connect to java.net.datagramsocket represents a UDP endpoint for transmitting data without a connection java.net.uri provides means to syntactically manipulate URIs java.net.url provides means to transmit data over specific application layer protocols java.net.inetaddress represents an IP address java.net.networkinterface provides means to enumerate network interfaces and their IP addresses
3 Network layers (the TCP/IP model) Application HTTP FTP SMTP DNS SSH Transport TCP UDP Internet IPv4 IPv6 Link Ethernet
4 TCP Transmission Control Protocol Connection oriented (client - server) Provides the ability to transmit streaming data Guarantees reliable, ordered delivery Controls flow and congestion UDP User Datagram Protocol Connectionless Transmits data in packets (datagrams) No guarantee of ordering or delivery Low latency
5 Sockets A socket is an endpoint for communication between two machines A socket address is a combination of an IP address and a port number A socket has typically two associated socket addresses the local address and the remote address
6 java.net.socket Socket() create an unconnected socket Socket(InetAddress address, int port) create a socket and connect to the specified IP address and port Socket(String host, int port) create a socket and connect to the specified host and port void connect(socketaddress endpoint) connect an unconnected socket InputStream getinputstream() get the stream used for reading bytes from the socket OutputStream getoutputstream() get the stream used for writing bytes to the socket
7 java.net.socket example #1 Socket s = new Socket(InetAddress.getLoopbackAddress(), 8080); OutputStream out = s.getoutputstream(); InputStream in = s.getinputstream(); byte[] request = {1, 1, 2, 3, 5, 8; out.write(request); byte[] response = new byte[10]; in.read(response); System.out.println("Client got: " + Arrays.toString(response)); s.close();
8 java.net.socket example #1 (v2) try ( Socket s = new Socket(InetAddress.getLoopbackAddress(), 8080); OutputStream out = s.getoutputstream(); InputStream in = s.getinputstream(); ) { byte[] request = {1, 1, 2, 3, 5, 8; out.write(request); byte[] response = new byte[10]; in.read(response); System.out.println("Client got: " + Arrays.toString(response));
9 java.net.serversocket ServerSocket() create an unbound server socket ServerSocket(int port) create a server socket and bind it to the given port void bind(socketaddress endpoint) bind an unbound server socket to a specific endpoint (address + port) Socket accept() listen for a connection and accept it
10 java.net.serversocket example #1 try ( ServerSocket server = new ServerSocket(8080); Socket client = server.accept(); InputStream in = client.getinputstream(); OutputStream out = client.getoutputstream(); ) { byte[] request = new byte[10]; int n = in.read(request); System.out.println("Server got: " + Arrays.toString(request)); for (int i = 0; i < n; i++) request[i]++; out.write(request);
11 Example #1 output Server got: [1, 1, 2, 3, 5, 8, 0, 0, 0, 0] Client got: [2, 2, 3, 4, 6, 9, 0, 0, 0, 0]
12 java.net.socket example #2 try ( Socket s = new Socket(InetAddress.getLoopbackAddress(), 8080); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(s.getOutputStream(), UTF_8)); BufferedReader reader = new BufferedReader( new InputStreamReader(s.getInputStream(), UTF_8)) ) { writer.write("ping\n"); writer.flush(); String response = reader.readline(); System.out.println("Client got: " + response);
13 java.net.serversocket example #2 try ( ServerSocket server = new ServerSocket(8080); Socket client = server.accept(); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(client.getOutputStream(), UTF_8)); BufferedReader reader = new BufferedReader( new InputStreamReader(client.getInputStream(), UTF_8)) ) { String request = reader.readline(); System.out.println("Server got: " + request); writer.write("pong\n"); writer.flush();
14 Example #2 output Server got: Ping Client got: Pong
15 Accepting multiple connections The server needs to be able to work with several clients simultaneously This can be achieved by using multiple threads try (ServerSocket server = new ServerSocket(8080)) { ExecutorService executor = Executors.newCachedThreadPool(); while (true) { Socket client = server.accept(); executor.execute(() -> { OutputStream out = client.getoutputstream(); InputStream in = client.getinputstream(); // perform I/O on the client ); executor.shutdown(); executor.awaittermination(5, TimeUnit.MINUTES);
16 java.net.datagramsocket DatagramSocket() create a datagram socket and bind it to any available port DatagramSocket(int port) create a datagram socket and bind it to the given port DatagramSocket(SocketAddress addr) create a datagram socket and bind it to the given address and port; passing null creates an unbound socket void bind(socketaddress addr) bind the socket to the given address and port void connect(inetaddress address, int port) connect the socket to the given address and port void send(datagrampacket packet) send a datagram packet from this socket void receive(datagrampacket packet) receive a datagram packet from this socket
17 java.net.datagramsocket example (endpoint #1) try (DatagramSocket socket = new DatagramSocket()) { byte[] data = {1, 1, 2, 3, 5, 8; DatagramPacket request = new DatagramPacket(data, data.length); request.setaddress(inetaddress.getloopbackaddress()); request.setport(8888); socket.send(request); DatagramPacket response = new DatagramPacket(new byte[10], 10); socket.receive(response); System.out.println( "Endpoint #1 got: " + Arrays.toString(response.getData()) + " from " + response.getsocketaddress());
18 java.net.datagramsocket example (endpoint #2) try (DatagramSocket socket = new DatagramSocket(8888)) { DatagramPacket request = new DatagramPacket(new byte[10], 10); socket.receive(request); byte[] data = Arrays.copyOf( request.getdata(), request.getlength()); System.out.println( "Endpoint #2 got: " + Arrays.toString(data) + " from " + request.getsocketaddress()); for (int i = 0; i < data.length; i++) data[i]++; DatagramPacket response = new DatagramPacket(data, data.length); response.setsocketaddress(request.getsocketaddress()); socket.send(response);
19 java.net.datagramsocket example output Endpoint #2 got: [1, 1, 2, 3, 5, 8] from / :53908 Endpoint #1 got: [2, 2, 3, 4, 6, 9, 0, 0, 0, 0] from / :8888
20 Socket channels (java.nio.channels) Access the same socket from different threads Manage multiple sockets in one thread Use special buffers for read/write operations
21 Socket channels example Selector selector = Selector.open(); for (int i = 0; i < 100; i++) { SocketChannel client = SocketChannel.open(); client.configureblocking(false); client.register(selector, OP_CONNECT OP_READ OP_WRITE); client.connect(...); while (true) { selector.select(); Set<SelectionKey> selectedkeys = selector.selectedkeys(); for (SelectionKey key : selectedkeys) { SocketChannel channel = (SocketChannel) key.channel(); if (key.isconnectable()) { // client connected if (key.iswritable()) { // write to the socket if (key.isreadable()) { // read from the socket
22 java.nio.bytebuffer ByteBuffer.allocate(int capacity) creates a buffer with the given capacity ByteBuffer.wrap(byte[] array) creates a buffer with the given underlying array int capacity() returns the capacity of the buffer int position() returns the current position of the buffer int limit() returns the limit of this buffer int remaining() returns the number of bytes between the current position and the limit
23 java.nio.bytebuffer Position Limit Capacity Buffer clear() clears the buffer sets the limit to the capacity and the position to 0 Buffer flip() flips the buffer sets the limit to the current position and sets the position to 0 Buffer rewind() rewinds the buffer leaves the limit unchanged and sets the position to 0
24 Using ByteBuffers with channels // Each client should have a unique buffer ByteBuffer buffer = ByteBuffer.allocate(1024); //... SocketChannel channel = (SocketChannel) key.channel(); if (key.isreadable()) { channel.read(buffer); // check the number of bytes in the buffer using // buffer.position() and act accordingly buffer.flip(); byte[] data = new byte[buffer.limit()]; buffer.get(data); // data now contains the bytes that were in the buffer buffer.clear();
25 Communicating through higher level protocols TCP/UDP is fairly low level It can get complicated very fast You will likely be reinventing the wheel a lot of times You are probably better off using a higher level protocol You can either use an existing one or develop your own
26 Application layer protocols An application layer protocol defines the rules for formatting certain messages It helps solve some complex communication issues authentication authorization metadata message structure Some well known protocols: HTTP web pages, REST APIs FTP file transfer SMTP sending RTP real-time audio/video streaming SSH secure operation of remote services
27 HTTP One of the most well-known and versatile application layer protocols Initially designed to transmit hypertext (web pages) HTTP has a simple request-response model Client sends a request Server sends a response Rinse and repeat The protocol is stateless, however state is often implemented on top of HTTP
28 Making an HTTP request by hand try ( Socket s = new Socket("freegeoip.net", 80); Writer writer = new OutputStreamWriter(s.getOutputStream(), UTF_8); BufferedReader reader = new BufferedReader( new InputStreamReader(s.getInputStream(), UTF_8)); ) { writer.write("" + "GET /json/ HTTP/1.1\r\n" + "Host: freegeoip.net\r\n" + "Connection: close\r\n" + "\r\n"); writer.flush(); String line; while ((line = reader.readline())!= null) System.out.println(line);
29 Making an HTTP request by hand (output) HTTP/ OK Content-Type: application/json Vary: Origin X-Database-Date: Wed, 07 Sep :05:53 GMT X-Ratelimit-Limit: X-Ratelimit-Remaining: 9993 X-Ratelimit-Reset: 2383 Date: Mon, 03 Oct :58:53 GMT Content-Length: 221 Connection: close {"ip":" ","country_code":"ee","country_name":"estonia","region_code":"78","region_name":"tartu","city":"tartu","zip_code ":"","time_zone":"europe/tallinn","latitude": ,"longitude": ,"metro_code":0
30 java.net.url URL(String spec) creates a URL from the given string URLConnection openconnection() returns an object representing the connection to the resource referred to by this URL InputStream openstream() opens a connection to this URL and returns an input stream for reading from that connection
31 java.net.url example URL url = new URL(" try (BufferedReader reader = new BufferedReader( new InputStreamReader(url.openStream(), UTF_8))) { String line; while ((line = reader.readline())!= null) System.out.println(line); Output: {"ip":" ","country_code":"ee","country_name":"estonia","region_code":"78","region_name":"tartu","city":"tartu","zip_code ":"","time_zone":"europe/tallinn","latitude": ,"longitude": ,"metro_code":0
32 java.net.url example (POST) URL url = new URL(" HttpURLConnection connection = (HttpURLConnection) url.openconnection(); connection.setrequestmethod("post"); connection.setdooutput(true); connection.setrequestproperty( "Content-Type", "application/x-www-form-urlencoded"); try (OutputStreamWriter writer = new OutputStreamWriter( connection.getoutputstream(), UTF_8)) { writer.write("b64=smf2ysbgdw5kyw1lbnrhbhm%3d"); writer.flush(); try (BufferedReader reader = new BufferedReader( new InputStreamReader(connection.getInputStream(), UTF_8))) { String line; while ((line = reader.readline())!= null) System.out.println(line);
33 java.net.url example output (POST) <!doctype html> <html lang="en">... <textarea name="ascii" id="ascii">java Fundamentals</textarea>...
34 Apache HttpComponents String response = Request.Get(" System.out.println(response); String response = Request.Post(" "SmF2YSBGdW5kYW1lbnRhbHM=").build()).execute().returnContent().asString(); System.out.println(response);
35 Jetty Allows to easily embed an HTTP server into any application. <dependency> <groupid>org.eclipse.jetty</groupid> <artifactid>jetty-server</artifactid> <version> v </version> </dependency>
36 Embedded Jetty class MyHandler extends AbstractHandler public void handle(string path, Request baserequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Use request.getpathinfo() to access the path // and request.getquerystring() to access the query string baserequest.sethandled(true); response.setstatus(httpservletresponse.sc_ok); response.getwriter().println("hello"); Server server = new Server(8080); server.sethandler(new MyHandler()); server.start(); server.join();
37 Homework Implement a simple chat client-server application. The client has been written for you, you need to write the server The server must be able to handle multiple connected clients Whenever a client connects to the server, it first sends its name, the server must keep track of the names Whenever the server receives a message from a client, it must prefix the message with the name of the client and send this prefixed message to all other connected clients The server must also send X has joined and X has left messages to all clients (a client joins when he connects, and leaves when he disconnects) The server must have an HTTP endpoint (on port 8080) that returns the names of all currently connected clients (just a basic list, one name per line) You ll find the client here:
38 Homework Here is some sample output from a client. Enter name: chip Connecting Connected, you can type your messages now dale has joined hey dale dale: hi let's go get some apples dale: sure, why not dale: let's meet at your place, I'll be there in 10 dale has left /q
Distributed Systems Recitation 2. Tamim Jabban
15-440 Distributed Systems Recitation 2 Tamim Jabban Agenda Communication via Sockets in Java (this enables you to complete PS1 and start P1 (goes out today!)) Multi-threading in Java Coding a full Client-Server
More informationLecture 3: Socket Programming
Lecture 3: Socket Programming Prof. Shervin Shirmohammadi SITE, University of Ottawa Fall 2005 CEG4183/ELG4183 3-1 Sockets From a logical perspective, a Socket is a communication end point. It is not a
More informationDistributed Systems Recitation 2. Tamim Jabban
15-440 Distributed Systems Recitation 2 Tamim Jabban Project 1 Involves creating a Distributed File System (DFS) Released yesterday When/If done with PS1, start reading the handout Today: Socket communication!
More informationNetworking and Security
Chapter 03 Networking and Security Mr. Nilesh Vishwasrao Patil Government Polytechnic Ahmednagar Socket Network socket is an endpoint of an interprocess communication flow across a computer network. Sockets
More informationJAVA - NETWORKING (SOCKET PROGRAMMING)
JAVA - NETWORKING (SOCKET PROGRAMMING) http://www.tutorialspoint.com/java/java_networking.htm Copyright tutorialspoint.com The term network programming refers to writing programs that execute across multiple
More informationOutlines. Networking in Java. Internet hardware structure. Networking Diagram. IP Address. Networking in Java. Networking basics
G52APR Application programming Networking in Java Michael Li http://www.cs.nott.ac.uk/~jwl/g52apr Outlines Networking basics Network architecture IP address and port Server-client model TCP and UDP protocol
More informationAdvanced Java Programming. Networking
Advanced Java Programming Networking Eran Werner and Ohad Barzilay Tel-Aviv University Advanced Java Programming, Spring 2006 1 Overview of networking Advanced Java Programming, Spring 2006 2 TCP/IP protocol
More informationNetworking Basics. network communication.
JAVA NETWORKING API Networking Basics When you write Java programs that communicate over the network, you are programming at the application layer. Typically, you don't need to concern yourself with the
More informationCOMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming
COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network
More informationNetwork Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff
Network Programming by Vlad Costel Ungureanu for Learn Stuff Java Network Protocols 2 Java Network Protocols 3 Addresses Innet4Address (32-bit) 85.122.23.145 - numeric pentalog.com symbolic Innet6Address
More informationJAVA Network API. 2 - Connection-Oriented vs. Connectionless Communication
JAVA Network API To be discussed 1 - java.net... 1 2 - Connection-Oriented vs. Connectionless Communication... 1 3 - Connectionless:... 1 4 - Networking Protocols... 2 5 - Sockets... 2 6 - Multicast Addressing...
More informationUnit 9: Network Programming
Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 9: Network Programming 1 1. Background 2. Accessing
More informationNetworking with java (socket programming) a brief study
REVIEWS COMPUTER ENGINEERING Discovery Engineering, Volume 2, Number 7, October 2013 ISSN 2320 6675 EISSN 2320 6853 Discovery Engineering REVIEWS COMPUTER ENGINEERING discovery Engineering Networking with
More informationOutline of Topics. UDP Socket Java Programming. Multicast in Java. Real-time protocol (RTP) XMPP and Jingle protocols. Java I/O and New IO (NIO)
Outline Outline of Topics UDP Socket Java Programming Multicast in Java Real-time protocol (RTP) XMPP and Jingle protocols Java I/O and New IO (NIO) UDP Socket Java Programming User Datagram Protocol (UDP)
More informationTCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket
Objectives TCP connections To understand programming of clients that connect to servers via TCP To understand the basics of programming of servers that accept TCP connections To practice programming of
More informationC18: Network Fundamentals and Reliable Sockets
CISC 3120 C18: Network Fundamentals and Reliable Sockets Hui Chen Department of Computer & Information Science CUNY Brooklyn College 4/16/2018 CUNY Brooklyn College 1 Outline Networking fundamentals Network
More informationIntroduction 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 informationNetworking. Lecture 25 ish? COP 3252 Summer July 11, 2017
Networking Lecture 25 ish? COP 3252 Summer 2017 July 11, 2017 Open-Read/Write-Close The Unix I/O system follows a paradigm usually referred to as Open-Read/Write-Close. Before a program/process can perform
More informationJava.net Package and Classes(Url, UrlConnection, HttpUrlConnection)
Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection) Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in
More informationPrinciples of Software Construction. Introduction to networks and distributed systems School of Computer Science
Principles of Software Construction Introduction to networks and distributed systems Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 5 Best Frameworks available tonight Or
More informationCSCD 330 Network Programming Spring 2018
CSCD 330 Network Programming Spring 2018 Lecture 6 Application Layer Socket Programming in Java Reading for Java Client/Server see Relevant Links Some Material in these slides from J.F Kurose and K.W.
More informationInterprocess Communication
Interprocess Communication Nicola Dragoni Embedded Systems Engineering DTU Informatics 4.2 Characteristics, Sockets, Client-Server Communication: UDP vs TCP 4.4 Group (Multicast) Communication The Characteristics
More informationCh.11 Nonblocking I/O
CSB541 Network Programming 網路程式設計 Ch.11 Nonblocking I/O 吳俊興國立高雄大學資訊工程學系 Outline 11.1 An Example Client 11.2 An Example Server 11.3 Buffers 11.4 Channels 11.5 Readiness Selection 2 Java I/O Two typical
More informationSocket 101 Excerpt from Network Programming
Socket 101 Excerpt from Network Programming EDA095 Nätverksprogrammering Originals by Roger Henriksson Computer Science Lund University Java I/O Streams Stream (swe. Ström) - A stream is a sequential ordering
More informationCSCD 330 Network Programming Winter 2019
CSCD 330 Network Programming Winter 2019 Lecture 7 Application Layer Socket Programming in Java Reading: Chapter 2, Java links Relevant Links page Some Material in these slides from J.F Kurose and K.W.
More informationLecture 3. Java Socket Programming. TCP, UDP and URL
Lecture 3 TCP, UDP and URL 1 Java Sockets Programming The package java.net provides support for sockets programming (and more). Typically you import everything defined in this package with: import java.net.*;
More informationIntroduction to Network Programming using Java
Introduction to Network Programming using Java 1 Development platform Starting Point Unix/Linux/Windows available in the department or computing centre More information http://www.tkk.fi/cc/computers/
More informationCS September 2017
Machine vs. transport endpoints IP is a network layer protocol: packets address only the machine IP header identifies source IP address, destination IP address Distributed Systems 01r. Sockets Programming
More informationCSCD 330 Network Programming Spring 2018
CSCD 330 Network Programming Spring 2018 Lecture 7 Application Layer Socket Programming in Java Reading: Chapter 2, Java links Relevant Links page Some Material in these slides from J.F Kurose and K.W.
More informationSERVER/CLIENT NETWORKING AT JAVA PLATFORM
SERVER/CLIENT NETWORKING AT JAVA PLATFORM Vibhu Chinmay, Shubham Sachdeva Student (B.tech5 th sem) Department of Electronics and Computers Engineering Dronacharya College of Engineering, Gurgaon-123506,
More informationIntroduction to NIO: New I/O
Chapter 2 Introduction to NIO: New I/O Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2004-09-01 ATIJ 2: Introduction to NIO: New I/O 2-1/36
More informationConnecting to a Server Implementing Servers Making URL Connections Advanced Socket Programming
Course Name: Advanced Java Lecture 11 Topics to be covered Connecting to a Server Implementing Servers Making URL Connections Advanced Socket Programming Introduction Internet and WWW have emerged as global
More informationCS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.
CS 355 Computer Networking Wei Lu, Ph.D., P.Eng. Chapter 2: Application Layer Overview: Principles of network applications? Introduction to Wireshark Web and HTTP FTP Electronic Mail: SMTP, POP3, IMAP
More informationNetwork. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark
Network Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Outline Socket programming If we have the time: Remote method invocation (RMI) 2 Socket Programming Sockets
More informationImproving Java Network Programming. Brian Runk, 25 Apr 2006
Improving Java Network Programming Brian Runk, b.runk@morganstanley.com 25 Apr 2006 Topics Background A simple distributed application java.net programming model java.nio programming model A better programming
More informationDistributed Systems. 3. Access to the Transport Layer. Werner Nutt
Distributed Systems 3. Access to the Transport Layer Werner Nutt 1 Access to the Transport Layer Processes issue requests to the transport layer (i.e., the application takes the initiative, not the transport
More informationIntroduction to Java.net Package. CGS 3416 Java for Non Majors
Introduction to Java.net Package CGS 3416 Java for Non Majors 1 Package Overview The package java.net contains class and interfaces that provide powerful infrastructure for implementing networking applications.
More informationPrevious lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL
Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 What is a thread Why use multiple threads Issues and problems involved Java threads Natasha Alechina School of Computer
More informationNetworking: IPv6, UDP and TCP. Network Programming in Java UDP and TCP
Networking: IPv6, UDP and TCP Network Programming in Java UDP and TCP SCOMRED, November 2018 Instituto Superior de Engenharia do Porto (ISEP) Departamento de Engenharia Informática(DEI) SWitCH Computing
More informationC19: User Datagram and Multicast
CISC 3120 C19: User Datagram and Multicast Hui Chen Department of Computer & Information Science CUNY Brooklyn College 4/18/2018 CUNY Brooklyn College 1 Outline Recap Network fundamentals IPv4, IPv6 addresses
More informationCommunication Paradigms
Communication Paradigms Nicola Dragoni Embedded Systems Engineering DTU Compute 1. Interprocess Communication Direct Communication: Sockets Indirect Communication: IP Multicast 2. High Level Communication
More informationUnit 1 Java Networking
Q1. What is Server Socket? Discuss the difference between the Socket and ServerSocket class. The ServerSocket class (java.net) can be used to create a server socket. This object is used to establish communication
More informationJava Networking (sockets)
Java Networking (sockets) Rui Moreira Links: http://java.sun.com/docs/books/tutorial/networking/toc.html#sockets http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets_p.html Networking Computers
More informationNetwork Programming Benoît Garbinato
Network Programming Benoît Garbinato 1 Network programming Network programming is not distributed programming (somewhat lower-level) They both rely on: computers as processing & storage resources a network
More informationInternet Protocol. Chapter 5 Protocol Layering. Juho Kim Graduate School of Information & Technology Sogang University
Internet Protocol Chapter 5 Protocol Layering Juho Kim Graduate School of Information & Technology Sogang University Department of of Computer Science and and Engineering, Sogang University Page 1 CAD
More informationJava Support for developing TCP Network Based Programs
Java Support for developing TCP Network Based Programs 1 How to Write a Network Based Program (In Java) As mentioned, we will use the TCP Transport Protocol. To communicate over TCP, a client program and
More informationBasic Java Network Programming. CS211 July 30 th, 2001
Basic Java Network Programming CS211 July 30 th, 2001 The Network and OSI Model IP Header TCP Header TCP/IP: A Paradox TCP Connection Oriented and Connectionless Protocols Reliable: no loss, or duplication,
More informationJava Technologies. Lecture VII. Valdas Rapševičius. Vilnius University Faculty of Mathematics and Informatics
Preparation of the material was supported by the project Increasing Internationality in Study Programs of the Department of Computer Science II, project number VP1 2.2 ŠMM-07-K-02-070, funded by The European
More informationObject-Oriented Programming in Java
CSCI/CMPE 3326 Object-Oriented Programming in Java 1. Socket Programming Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Two types of TCP Socket java.net.serversocket
More informationOBJECT ORIENTED PROGRAMMING
1 OBJECT ORIENTED PROGRAMMING Lecture 14 Networking Basics Outline 2 Networking Basics Socket IP Address DNS Client/Server Networking Class & Interface URL Demonstrating URL Networking 3 Java is practically
More informationPieter van den Hombergh Richard van den Ham. March 17, 2018
: Network : Network, Object Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek March 17, 2018 /FHTenL : Network March 17, 2018 1/21 Topics, Object Some everyday life
More informationConstruction d Applications Réparties / Master MIAGE
Construction d Applications Réparties / Master MIAGE Networking Giuseppe Lipari CRiSTAL, Université de Lille January 26, 2016 Outline Introduction Networking Transport Protocols TCP and UDP Addressing
More informationChapter 11. Application-Layer Elements Ports
Chapter 11 Application-Layer Elements 11.1 Ports........................... 93 11.2 Sockets.......................... 95 11.2.1 Socket Domains, Types and Protocols....... 95 11.2.2 Operations on Sockets................
More informationIntroduction to Sockets 9/25/14
Introduction to Sockets 9/25/14 81 Remote communication Inter-process communication is at the heart of all distributed systems Using the network protocol stack on a node is the only way to communicate
More informationpublic static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));
Echo Client&Server Application EchoClient import java.net.*; import java.io.*; class EchoClient public static void main(string[] args) throws IOException if (args.length < 2) number>"); System.err.println("Usage:
More informationAssignment 1. Due date February 6, 2007 at 11pm. It must be submitted using submit command.
Assignment 1 Due date February 6, 2007 at 11pm. It must be submitted using submit command. Note: submit 4213 a1 . Read the manpages ("man submit") for more details on the submit command. It is
More informationJAVA SOCKET PROGRAMMING
JAVA SOCKET PROGRAMMING WHAT IS A SOCKET? Socket The combination of an IP address and a port number. (RFC 793 original TCP specification) The name of the Berkeley-derived application programming interfaces
More informationProject 0. Danyang Zhuo CSE sp Sec;on #2
Project 0 Danyang Zhuo CSE 461 15sp Sec;on #2 Proj0 You have to implement: Mul;- UDP Server Mul;- UDP Client Async IO UDP Server Async IO UDP Client Your server must support mul;ple clients Submit Format
More informationSOCKETS. 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 informationprotocols September 15,
Contents SCI 351 4 Protocols, WWW Internet applications WWW, document technology Lennart Herlaar Original slides by Piet van Oostrum September 15, 2003 SCI351-4 1 X SCI351-4 1 X Internet applications How
More informationCSE 461 Module 11. Connections
CSE 461 Module 11 Connections This Time More on the Transport Layer Focus How do we connect processes? Topics Naming processes Connection setup / teardown Flow control Application Presentation Session
More informationSocket programming. Complement for the programming assignment INFO-0010
Socket programming Complement for the programming assignment INFO-0010 Outline Socket definition Briefing on the Socket API A simple example in Java Multi-threading and Synchronization Example : HTTP protocol
More informationURL Kullanımı Get URL
Networking 1 URL Kullanımı Get URL URL info 2 import java.io.*; import java.net.*; public class GetURL { public static void main(string[] args) { InputStream in = null; OutputStream out = null; // Check
More informationWireshark screenshot of network traffic
s and s and Wireshark screenshot of network traffic 1/42 ing s and Hardware Protocols Software The network is the computer. (John Gage) 2/42 s and 3/42 s and 3/42 s and 3/42 ing Options s and type maximum
More informationTCP Networking in Java. Some reminders
TCP Networking in Java Some reminders Protocol Synonymous of Etiquette a code of behavior that delineates expectations for social behavior according to contemporary conventional norms within a society,
More informationTransport layer protocols. Lecture 15: Operating Systems and Networks Behzad Bordbar
Transport layer protocols Lecture 15: Operating Systems and Networks Behzad Bordbar 78 Interprocess communication Synchronous and asynchronous comm. Message destination Reliability Ordering Client Server
More information( A ) 1. WAP is a (A) protocol (B) hardware (C) software (D) network architecture
CS 742 Computer Communication Networks Final Exam - Name: Fall 2003 Part 1: (75 points - 3 points for each problem) ( A ) 1. WAP is a (A) protocol (B) hardware (C) software (D) network architecture ( C
More informationCSC 4900 Computer Networks: P2P and Sockets
CSC 4900 Computer Networks: P2P and Sockets Professor Henry Carter Fall 2017 Recap SMTP is the language that mail servers use to exchange messages. SMTP is push-based... why? You can run SMTP from a telnet
More informationCSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2012
Web clients in Java CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2012 The World Wide Web History Main components: URLs, HTTP Protocol, HTML Web support in Java Overview Connecting
More informationSTEPP Tagger 1. BASIC INFORMATION 2. TECHNICAL INFORMATION. Tool name. STEPP Tagger. Overview and purpose of the tool
1. BASIC INFORMATION Tool name STEPP Tagger Overview and purpose of the tool STEPP Tagger Part-of-speech tagger tuned to biomedical text. Given plain text, sentences and tokens are identified, and tokens
More informationJava A.1 TCP/IP TCP. TCP_RO.java import java.net.*; import java.io.*;
II A p.1 A Java C Java TCP/IP TCP/IP A.1 A.1.1 TCP TCP_RO.java public class TCP_RO { public static void main(string[] argv) { Socket readsocket = new Socket(argv[0], Integer.parseInt(argv[1])); InputStream
More informationSockets(for(Server( SKET4623(
! Reading(Material(7(( Sockets(for(Server( SKET4623( ABSTRACT( Socket(is(a(connection(between(two(hosts.(Java s(socket(class(is(used( by(both(client(and(server.(client(uses(socket(to(communicate(with(other(
More informationToday. cisc3120-fall2012-parsons-lectiv.2 2
NETWORK PROGRAMMING Today Today we will start to look at ways to write programs that operate over the network. We ll lok at two approaches that are supported by Java: Applets Socket-based communication
More informationJAVA 프로그래밍 II. Lab #7 (Networking) TCP Java Socket. TCP vs UDP 2017 학년도 1 학기 년봄학기 5/24/2017 박경신. Client. Server
Lab #7 (Networking) 2017 학년도 1 학기 JAVA 프로그래밍 II 기존요구사항분석 Lab #6 는 Thread, Runnable 과 SwingWorker 를이용한다양한멀티스레드기능을사용 Lab #7 는 TCP/UDP 등다양한네트워크프로그래밍기능을사용 TCP, UDP, HTTP, File Transfer 514770-1 2017 년봄학기 5/24/2017
More informationClient/Server Computing & Socket Programming
CPSC 852 Intering Client/Server Computing & Socket Programming Michele Weigle Department of Computer Science Clemson University mweigle@cs.clemson.edu http://www.cs.clemson.edu/~mweigle/courses/cpsc852
More informationChapter 2 Applications and
Chapter 2 Applications and Layered Architectures Sockets Socket API API (Application Programming Interface) Provides a standard set of functions that can be called by applications Berkeley UNIX Sockets
More informationInfo 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub
Lebanese University Faculty of Science I Master 1 degree Computer Science Info 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub Starting Network
More informationSC/CSE 3213 Winter Sebastian Magierowski York University CSE 3213, W13 L8: TCP/IP. Outline. Forwarding over network and data link layers
SC/CSE 3213 Winter 2013 L8: TCP/IP Overview Sebastian Magierowski York University 1 Outline TCP/IP Reference Model A set of protocols for internetworking The basis of the modern IP Datagram Exchange Examples
More informationInternet Technology 2/1/2016
Internet Technology //0 Internet Technology 0. Protocol Layers & Sockets Protocols Paul Krzyzanowski Rutgers University Spring 0 What s in the data? Protocols For effective communication same language,
More informationJava Basics 5 - Sockets. Manuel Oriol - May 4th, 2006
Java Basics 5 - Sockets Manuel Oriol - May 4th, 2006 Connected / Disconnected Modes Connected mode: path chosen and packets arrive all, in correct order (e.g. Phone) Disconnected mode: path not chosen
More informationWhat HTTP is : it forms elements (.html..xml) with programs (processes) running on the server (e.g. java) and on clients (e.g. javascript), cookies).
Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be interpreted by the browser What HTTP is : it forms
More informationUnix Network Programming
Unix Network Programming Remote Communication Dr Hamed Vahdat-Nejad Network Applications Types: Client Server Exampels: A web browser (client) Ap communicating with a Web server An FTP client Fetching
More informationNetworks and Network Programming
Networks and Network Programming Wireshark screenshot of network traffic 1/45 Networking Hardware Protocols Software The network is the computer. (John Gage) 2/45 3/45 3/45 3/45 Networking Options Network
More informationCS 5010: PDP. Lecture 11: Networks CS 5010 Fall 2017 Seattle. Adrienne Slaughter, Ph.D.
Lecture 11: Networks CS 5010 Fall 2017 Seattle CS 5010: PDP Adrienne Slaughter, Ph.D. ahslaughter@northeastern.edu Northeastern University 1 Agenda Networking Northeastern University 2 INTRODUCTION Northeastern
More informationTRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016
TRANSMISSION CONTROL PROTOCOL ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016 ETI 2506 - TELECOMMUNICATION SYLLABUS Principles of Telecom (IP Telephony and IP TV) - Key Issues to remember 1.
More informationJava for Interfaces and Networks
Java for Interfaces and Networks Threads and Networking Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces and Networks Lecture
More informationDistributed Systems COMP 212. Lecture 8 Othon Michail
Distributed Systems COMP 212 Lecture 8 Othon Michail HTTP Protocol Hypertext Transfer Protocol Used to transmit resources on the WWW HTML files, image files, query results, Identified by Uniform Resource
More information3. Remote Procedure Call
3. Remote Procedure Call Master II Software Engineering Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras imed@imed.ws Imed Bouchrika. Distributed Objects, Uni of Souk-Ahras
More informationJava 6. Network programming
Java 6 Network programming Internet Protocol (IP) IP addresses 32-bit number used to identify machines on the network e.g., 156.17.16.240 is the IP address of www.pwr.wroc.pl 127.0.0.1 always refers to
More informationJava Programming Language Advance Feature
Java Programming Language Advance Feature Peter.Cheng founder_chen@yahoo.com.cn http://www.huihoo.com 2004-04 Huihoo - Enterprise Open Source http://www.huihoo.com 1 Course Goal The main goal of this course
More informationSocket Programming. Omer Ozarslan
Socket Programming Omer Ozarslan omer@utdallas.edu 1 Outline Background Using TCP Example: hello_tcp Using UDP Example: hello_udp Blocking Calls and Threads Some Advises Code Examples Questions 2 Socket
More informationThe Transmission Control Protocol (TCP)
The Transmission Control Protocol (TCP) Application Services (Telnet, FTP, e-mail, WWW) Reliable Stream Transport (TCP) Unreliable Transport Service (UDP) Connectionless Packet Delivery Service (IP) Goals
More informationTCP/IP Overview. Basic Networking Concepts. 09/14/11 Basic TCP/IP Networking 1
TCP/IP Overview Basic Networking Concepts 09/14/11 Basic TCP/IP Networking 1 What is TCP/IP? TCP/IP is a name refers to an entire collection of data communication protocols: TCP: Transmission Control Protocol
More informationApplication Layer Introduction; HTTP; FTP
Application Layer Introduction; HTTP; FTP Tom Kelliher, CS 325 Feb. 4, 2011 1 Administrivia Announcements Assignment Read 2.4 2.6. From Last Time Packet-switched network characteristics; protocol layers
More informationRequirements. PA4: Multi-thread File Downloader Page 1. Assignment
PA4: Multi-thread File Downloader Page 1 Assignment What to Submit Write a program that downloads a file from the Internet using multiple threads. The application has a Graphical Interface written in JavaFX,
More informationCS193j, Stanford Handout #26. Files and Streams
CS193j, Stanford Handout #26 Summer, 2003 Manu Kumar Files and Streams File The File class represents a file or directory in the file system. It provides platform independent ways to test file attributes,
More informationReading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.
Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)
More informationDistributed Programming in Java
Distributed Programming in Java Networking (1) Motivating Scenario apps apps apps apps 2/28 apps nslookup A program for looking up IP addresses 3/28 1 InetAddress This class represents an IP address Each
More informationCS2307 NETWORKS LAB 1. Programs using TCP Sockets (like date and time server & client, echo server & client, etc.) 2. Programs using UDP Sockets
CS2307 NETWORKS LAB 1. Programs using TCP Sockets (like date and time server & client, echo server & client, etc.) 2. Programs using UDP Sockets (like simple DNS) 3. Programs using Raw sockets (like packet
More informationDATA COMMUNICATOIN NETWORKING
DATA COMMUNICATOIN NETWORKING Instructor: Ouldooz Baghban Karimi Course Book: Computer Networking, A Top-Down Approach By: Kurose, Ross Introduction Course Overview Basics of Computer Networks Internet
More information