JAVA. Sieťové programovanie
|
|
- Merilyn Jennings
- 5 years ago
- Views:
Transcription
1 JAVA Sieťové programovanie
2 Sieťové programovanie Sieťová knižnica jazyka JAVA bola vytvorená podľa súborovej knižnice Zapúzdrovanie pripojení do streamov Multithreading
3 Identifikácia počítača Každý počítač v Internete je jedinečne charakterizovaný IP adresou prideľovanou fixne (nemenne) alebo dynamicky prostredníctvom DHCP. Podobne má každý počítač meno zaznamenané v bázach dát DNS. Java umožňuje zistiť IP adresu počítača prostredníctvom volania metódy InetAddress.getByName(menoPočítača)
4 Identifikácia počítača import java.io.*; import java.net.*; public class WhoAmI { public static void main(string[] args) throws Exception { String meno = ""; InetAddress add; BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); System.out.print("Zadaj meno pocitaca: "); meno = in.readline(); catch (IOException e) { System.err.println("chyba s nacitanim"); add = InetAddress.getByName(meno); System.out.println(add);
5 Identifikácia počítača add = InetAddress.getByName(meno); System.out.println("meno/IP pocitaca: " + add); add = InetAddress.getByName(null); System.out.println("meno/IP localhost: " + add); add = InetAddress.getLocalHost(); System.out.println("meno/IP host pocitaca: " + add); System.out.println("meno host: " + add.gethostname()); System.out.println("IP host: " + add.gethostaddress());
6 Servery a klienti Server je počítač, ktorý čaká na prichadzajúce spojenie. Klient má za úlohu toto pripojenie vytvoriť. Rozdelenie Klient-Server po vytvorení spojenia stráca význam. Komunikácia prebieha ako keby to boli len súbory(.read,.write...)
7 Sokety Sokety (angl. sockets) sú softvérovou abstrakciou fyzických konektorov (zásuviek) komunikačného spojenia medzi počítačmi ServerSocket a Socket ServerSocket.accept(); InputStream a OutputStream
8 import java.io.*; import java.net.*; public class MojPrvyServer { private static ServerSocket ss; public static final int PORT = 8081; public static void main(string[] args) throws IOException { ss = new ServerSocket(PORT); System.out.println("Server beží: " + ss); Socket s = ss.accept(); BufferedReader in = new BufferedReader( new InputStreamReader( s.getinputstream())); PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter( s.getoutputstream())), true); while(true) { String citam = in.readline(); if (citam.equals("end")) break; System.out.println ("Server prijíma: " + citam); System.out.println ("Server posiela: " + citam); out.println(citam); catch (IOException e) { System.err.println("IOException"); finally { System.out.println("Uzatváram sokety"); s.close(); finally { ss.close();
9 import java.io.*; import java.net.*; public class MojPrvyKlient { public static void main(string[] args) throws IOException { InetAddress ip = InetAddress.getByName(null); Socket s = new Socket(ip, MojPrvyServer.PORT); System.out.println("Štartuje klient: " + s); BufferedReader in = new BufferedReader( new InputStreamReader( s.getinputstream())); PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter( s.getoutputstream())), true); for(int i = 0; i < 5; i ++) { out.println("posielam " + i); System.out.println ("Klient posiela: " + "posielam " + i); System.out.println ("Klient prijíma: " + in.readline()); out.println("end"); catch (IOException e) { System.out.println("IOException"); finally { s.close();
10 Viacvláknový server Predchadzajúci server dokázal obslúžiť iba jedného klienta. Aby sme mohli obsluhovať teoreticky neobmedzené množstvo klientov použijeme Vlákna.
11 import java.net.*; import java.io.*; public class MultivlaknovyServer { private static ServerSocket ss; public static final int PORT = 8081; public static void main(string[] args) throws IOException { ss = new ServerSocket(PORT); System.out.println("Server beží: " + ss); while(true) { Socket s = ss.accept(); new ObsluhaJednehoKlienta(s); finally { ss.close();
12 class ObsluhaJednehoKlienta extends Thread { private Socket socket; private BufferedReader in; private PrintWriter out; public ObsluhaJednehoKlienta(Socket s) { socket = s; in = new BufferedReader( new InputStreamReader( s.getinputstream())); out = new PrintWriter( new BufferedWriter( new OutputStreamWriter( s.getoutputstream())), true); catch (IOException e) { System.err.println("IOException"); start(); public void run() { while(true) { String citam = in.readline(); if (citam.equals("end")) break; System.out.println("Server prijíma: " + citam); System.out.println("Server posiela: " + citam); out.println(citam); catch (IOException e) { System.err.println ("Chyba so zapisovaním alebo čítanim"); finally { socket.close(); catch(ioexception e) { System.err.println ("Nepodarilo sa uzavrieť soket");
13 Datagramy Nevýhody: Neisté doručenie paketov Neisté poradie doručenia Výhody: Rýchlosť prenosu Použitie: Pri prenose zvuku, prenos času
14 Datagramy Nerozlišujeme medzi serverom a klientom. Na oboch stranách sa vytvára DatagramSocket. Paket datagramu musí vedieť nielen kam ide ale aj odkiaľ ide.
15 Príklad triedy pre tvorbu DatagramPacketu a Stringu z Paketu import java.net.*; public class Dgram { public static DatagramPacket todatagram( String s, InetAddress destia, int destport) { byte[] buf = s.getbytes(); return new DatagramPacket(buf, buf.length, destia, destport); } public static String tostring(datagrampacket p){ return new String(p.getData(), 0, p.getlength()); } }
16 import java.net.*; import java.io.*; import java.util.*; public class ChatterServer { static final int INPORT = 1711; private byte[] buf = new byte[1000]; private DatagramPacket dp = new DatagramPacket(buf, buf.length); // Can listen & send on the same socket: private DatagramSocket socket; public ChatterServer() { socket = new DatagramSocket(INPORT); System.out.println("Server started"); while(true) { // Block until a datagram appears: socket.receive(dp); String rcvd = Dgram.toString(dp) + ", from address: " + dp.getaddress() + ", port: " + dp.getport(); System.out.println(rcvd); String echostring = "Echoed: " + rcvd; // Extract the address and port from the // received datagram to find out where to // send it back: DatagramPacket echo = Dgram.toDatagram(echoString, dp.getaddress(), dp.getport()); socket.send(echo); catch(socketexception e) { System.err.println("Can't open socket"); System.exit(1); catch(ioexception e) { System.err.println("Communication error"); e.printstacktrace(); public static void main(string[] args) { new ChatterServer();
17 import java.lang.thread; import java.net.*; import java.io.*; public class ChatterClient extends Thread { // Can listen & send on the same socket: private DatagramSocket s; private InetAddress hostaddress; private byte[] buf = new byte[1000]; private DatagramPacket dp = new DatagramPacket(buf, buf.length); private int id; public ChatterClient(int identifier) { id = identifier; // Auto-assign port number: s = new DatagramSocket(); hostaddress = InetAddress.getByName("localhost"); catch(unknownhostexception e) { System.err.println("Cannot find host"); System.exit(1); catch(socketexception e) { System.err.println("Can't open socket"); e.printstacktrace(); System.exit(1); System.out.println("ChatterClient starting");
18 public void run() { for(int i = 0; i < 25; i++) { String outmessage = "Client #" + id + ", message #" + i; // Make and send a datagram: s.send(dgram.todatagram(outmessage, hostaddress, ChatterServer.INPORT)); // Block until it echoes back: s.receive(dp); // Print out the echoed contents: String rcvd = "Client #" + id + ", rcvd from " + dp.getaddress() + ", " + dp.getport() + ": " + Dgram.toString(dp); System.out.println(rcvd); catch(ioexception e) { e.printstacktrace(); System.exit(1); public static void main(string[] args) { for(int i = 0; i < 10; i++) new ChatterClient(i).start();
19 KONIEC
Network 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 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 informationIntroduction to Sockets
Introduction to Sockets Sockets in Java 07/02/2012 EPL 602 1 Socket programming Goal: learn how to build client/server application that communicate using sockets Socket API o introduced in BSD4.1 UNIX,
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 informationJava Socket Workshop. July Purpose of this workshop:
Java Socket Workshop July 2012 Purpose of this workshop: The objective of this workshop is to gain experience with writing and compiling programs using the Java programming language. The exercises provide
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 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 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 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 informationNetworking Code CSCI 201 Principles of Software Development
Networking Code CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Server Networking Client Networking Program Outline USC CSCI 201L Server Software A server application
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 informationCPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary
CPSC 441 Tutorial TCP Server Department of Computer Science University of Calgary TCP Socket Client Server Connection Request Server Listening on welcoming socket Client Socket Server Socket Data Simple
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 (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 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 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 informationPrinciples, Models and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models and Applications for Distributed Systems M Lab assignment 2 (worked-out) Connectionless Java Sockets Luca Foschini 2010/2011 Exercise
More informationJava for Interfaces and Networks (DT3010, HT11)
Java for Interfaces and Networks (DT3010, HT11) Networking with Threads and Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces
More informationMYcsvtu Notes. Experiment-1. AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions
Experiment-1 AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions String Xor(String s1,string s2) char s1array[]=s1.tochararray(); char s2array[]=s2.tochararray();
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 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 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 informationTopic 10: Network Programming
Topic 10: Network Programming Client-Server Model Host and Port Socket Implementing Client Implementing Server Implementing Server for Multiple Clients Client-Server Model Clients Request a server to provide
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 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 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 informationTCP and UDP Socket Programming in JAVA TCP Socket Programming 1. Write code for Client and save in GreetingClient.java
TCP Socket Programming 1. Write code for Client and save in GreetingClient.java // File Name GreetingClient.java public class GreetingClient public static void main(string [] args) String servername =
More informationTransmission Control Protocol
Transmission Control Protocol Descrizione livelli TCP/IP fisico: hardware e protocollo scheda di rete rete: protocollo IP trasporto: protocolli TCP e UDP applicazione: telnet, ssh, i vostri programmi Protocollo
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 informationJava for Interfaces and Networks (DT3029)
Java for Interfaces and Networks (DT3029) Lecture 4 Networking with Threads and Containers Federico Pecora federico.pecora@oru.se Center for Applied Autonomous Sensor Systems (AASS) Örebro University,
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 informationSoftware Practice 1 - Socket
Software Practice 1 - Socket Terms of socket programming Socket Implementation (TCP, UDP) Socket with multithread Serialization Lab practice Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim T.A. Sujin
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 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 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 informationSteps for Implementing a Server
Agenda 5 Steps for creating a server 1. Create a ServerSocket object 2. Create a Socket object from ServerSocket 3. Create an input stream 4. Create an output stream 5. Do I/O with input and output streams
More informationJava for Interfaces and Networks (DT3029)
Java for Interfaces and Networks (DT3029) Lecture 3 Threads and Networking Federico Pecora federico.pecora@oru.se Center for Applied Autonomous Sensor Systems (AASS) Örebro University, Sweden Capiscum
More informationNetwork Programming: Servers
2012 Marty Hall Network Programming: Servers Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/java.html 3 Customized Java EE Training: http://courses.coreservlets.com/
More informationLab 1 : Java Sockets
Lab 1 : Java Sockets 1. Goals In this lab you will work with a low-level mechanism for distributed communication. You will discover that Java sockets do not provide: - location transparency - naming transparency
More informationCPSC 441 UDP Socket Programming. Department of Computer Science University of Calgary
CPSC 441 UDP Socket Programming Department of Computer Science University of Calgary Socket programming using UDP (vs TCP) UDP: no connection between client and server vno handshaking vsender explicitly
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 informationAssignment, part1: feedback and common mistakes. INFO-0010 Samuel HIARD
Assignment, part1: feedback and common mistakes INFO-0010 Samuel HIARD Grades? Not yet Work done at ~70-80% ETA : First week after Spring holidays (should be) Content of the presentation The code of all
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 informationJava in 21 minutes. Hello world. hello world. exceptions. basic data types. constructors. classes & objects I/O. program structure.
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
More informationChapter 12. Network Programming
Chapter 12 Network Programming What is in This Chapter? This chapter explains how to connect your JAVA application to a network. You will learn how to read files from over the internet as well as have
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 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 informationInternet Technology 2/7/2013
Sample Client-Server Program Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 To illustrate programming with TCP/IP sockets, we ll write a small client-server
More informationIT101. File Input and Output
IT101 File Input and Output IO Streams A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents
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 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 informationWeek 13 Lab - Exploring Connections & Remote Execution
Week 13 Lab - Exploring Connections & Remote Execution COSC244 & TELE202 1 Assessment This lab is worth 0.5%. The marks are awarded for completing the programming exercise and answering the questions.
More informationInput from Files. Buffered Reader
Input from Files Buffered Reader Input from files is always text. You can convert it to ints using Integer.parseInt() We use BufferedReaders to minimize the number of reads to the file. The Buffer reads
More informationPrinciples, Models, and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Lab assignment 4 (worked-out) Connection-oriented Java Sockets Luca Foschini Winter
More informationA socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs.
PART 24 Java Network Applications 24.1 Java Socket Programming A socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs. A server
More informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Winter 2015 Reading: Chapter 2, Relevant Links Some Material in these slides from J.F Kurose and K.W. Ross All material copyright
More informationCPSC 441 Tutorial - 11 UDP Socket Programming Department of Computer Science University of Calgary
CPSC 441 Tutorial - 11 UDP Programming Department of Computer Science University of Calgary TCP Vs UDP Input: receives packet (TCP receives byte stream ) Output: sends packet (TCP sends byte stream ) What
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 informationUDP Sockets TCP guarantees the delivery of packets and preserves their order on destination. Sometimes these features are not required, since they do
UDP Sockets TCP guarantees the delivery of packets and preserves their order on destination. Sometimes these features are not required, since they do not come without performance costs, it would be better
More informationDistributed Programming - Sockets
Distributed Programming - Sockets Piet van Oostrum May 25, 2009 Concurrency In praktische situaties krijgen we concurrency door: Processen Threads Interrupts (alleen intern in het O.S.) Processen Onafhankelijke
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 informationCSPP : Introduction to Object-Oriented Programming
CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text
More informationCS 351 Design of Large Programs Sockets Example
CS 351 Design of Large Programs Sockets Example Brooke Chenoweth University of New Mexico Spring 2019 Socket Socket(String host, int port) InputStream getinputstream() OutputStream getoutputstream() void
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 informationPrinciples, Models, and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Exercitation 3 Connected Java Sockets Jacopo De Benedetto Distributed architecture
More informationDM550 / DM857 Introduction to Programming. Peter Schneider-Kamp
DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ IN & OUTPUT USING STREAMS 2 Streams streams are
More informationpackage p1; public class Derivation extends Protection { public Derivation() { System.out.println("Derived class constructor");
PROGRAM:1 WAP to implement the packages //package 1: package p1; public class Protection int n=1; public int n_pub=2; private int n_pri=3; protected int n_pro=4; public Protection () System.out.println("Base
More informationMulti-threaded Web Server (Assignment 1) Georgios Georgiadis
Multi-threaded Web Server (Assignment 1) Georgios Georgiadis Overview Multi-threaded Web Server What to do and how to do it HTTP messages Processes and threads ComputerComm '09 2 Multi-threaded Web Server
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 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 informationSpecial error return Constructors do not have a return value What if method uses the full range of the return type?
23 Error Handling Exit program (System.exit()) usually a bad idea Output an error message does not help to recover from the error Special error return Constructors do not have a return value What if method
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 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 informationBrickNet (cont d) Other Academic Projects
BrickNet (cont d) Object-request brokers on the servers Aimed for collaborative design environments each node is responsible for its part of design and for sharing that information Also, networked games,
More informationFile IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20
File IO Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 I/O Package Overview Package java.io Core concept: streams Ordered sequences of data that have a source
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 informationGetting Started in Java. Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park
Getting Started in Java Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park Hello, World In HelloWorld.java public class HelloWorld { public static void main(string [] args) { System.out.println(
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 informationI/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O
I/O 10-7-2013 I/O in Java I/O streams vs. Reader/Writer HW#3 due today Reading Assignment: Java tutorial on Basic I/O public class Swimmer implements Cloneable { public Date geteventdate() { return (Date)
More informationProject Report On. Multiple Client and Server ChatApplication using Multicast in Java WindowBuilder
Project Report On Multiple Client and Server ChatApplication using Multicast in Java WindowBuilder B.Sc. in Information and Communications Engineering Department of ECE East West University,Dhaka Bangladesh
More informationVerteilte Systeme UE Important Code
Verteilte Systeme UE Important Code Lab 1 Create ServerSocket ServerSocket serversocket = new ServerSocket(tcpPort); //throws IOException Accept ClientSocket Socket clientsocket = serversocket.accept();
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 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 informationSocket Programming(TCP & UDP) Sanjay Chakraborty
Socket Programming(TCP & UDP) Sanjay Chakraborty Computer network programming involves writing computer programs that enable processes to communicate with each other across a computer network. The endpoint
More informationDarshan Institute of Engineering & Technology for Diploma Studies
Streams A stream is a sequence of data. In Java a stream is composed of bytes. In java, 3 streams are created for us automatically. 1. System.out : standard output stream 2. System.in : standard input
More informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Spring 2018 Reading: Chapter 2, Relevant Links - Threads Some Material in these slides from J.F Kurose and K.W. Ross All material
More informationCommunication in Distributed Systems: Sockets Programming. Operating Systems
Communication in Distributed Systems: Sockets Programming Operating Systems TCP/IP layers Layers Message Application Transport Internet Network interface Messages (UDP) or Streams (TCP) UDP or TCP packets
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 informationSOURCE CODE. //Socket Programming using TCP Sockets. Server.java
SOURCE CODE //Socket Programming using TCP Sockets Server.java import java.io.*; import java.net.*; public class Server public static void main (String args[]) throws Exception ServerSocket sersock=new
More informationByte and Character Streams. Reading and Writing Console input and output
Byte and Character Streams Reading and Writing Console input and output 1 I/O basics The io package supports Java s basic I/O (input/output) Java does provide strong, flexible support for I/O as it relates
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 informationChapter 10. IO Streams
Chapter 10 IO Streams Java I/O The Basics Java I/O is based around the concept of a stream Ordered sequence of information (bytes) coming from a source, or going to a sink Simplest stream reads/writes
More informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Spring 2017 Reading: Chapter 2, Relevant Links - Threads Some Material in these slides from J.F Kurose and K.W. Ross All material
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 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 informationCOMP 213. Advanced Object-oriented Programming. Lecture 19. Input/Output
COMP 213 Advanced Object-oriented Programming Lecture 19 Input/Output Input and Output A program that read no input and produced no output would be a very uninteresting and useless thing. Forms of input/output
More informationTHIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM
UNIVERSITY OF LONDON GOLDSMITHS COLLEGE B. Sc. Examination 2012 COMPUTER SCIENCE IS52025A Internet and Distributed Programming Duration: 2 hours 15 minutes Date and time: There are five questions in this
More informationJava Input/Output. 11 April 2013 OSU CSE 1
Java Input/Output 11 April 2013 OSU CSE 1 Overview The Java I/O (Input/Output) package java.io contains a group of interfaces and classes similar to the OSU CSE components SimpleReader and SimpleWriter
More informationTitle Description Participants Textbook
Podcast Ch23c Title: Binary Files Description: Overview of binary files; DataInputStream; DataOutputStream; Program 23.1; file compression Participants: Barry Kurtz (instructor); John Helfert and Tobie
More information