Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

Size: px
Start display at page:

Download "Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff"

Transcription

1 Network Programming by Vlad Costel Ungureanu for Learn Stuff

2 Java Network Protocols 2

3 Java Network Protocols 3

4 Addresses Innet4Address (32-bit) numeric pentalog.com symbolic Innet6Address (128-bit) 2002:0:0:0:0:0:557a:1791 Types of addresses unicast multicast localhost ( ) 4

5 Ports A port is a 16 bit number that uniquely identifies a process that provides network services Port number values: Possible values: Reserved values: (usually for OS services or well known applications) 5

6 Server Client Model Server offers network services responds at a specific port needs to be able to handle concurrent requests Client initiates the conversation with the server needs to know the network address and the port of the server requests a specific service from the server 6

7 Sockets 7

8 Sockets Socket = software abstraction describing the edges of a connection TCP: Socket, ServerSocket UDP: DatagramSocket InetSocketAddress IP address, port host name, port 8

9 TCP Servers public class SimpleServer { public SimpleServer() throws IOException { ServerSocket serversocket = null ; try { serversocket = new ServerSocket(8100); while ( true ) { Socket socket = serversocket.accept(); // execute client request new ClientThread(socket).start(); } } catch ( IOException e) { System.err. println ( You should log this error! ); } finally { serversocket.close(); } } public static void main ( String [] args ) throws IOException { SimpleServer server = new SimpleServer (); }} 9

10 TCP Response class ClientThread extends Thread { private Socket socket = null ; public ClientThread ( Socket socket ) { this.socket = socket ; } public void run () { try { BufferedReader in = new BufferedReader ( new InputStreamReader (socket.getinputstream())); String request= in.readline (); PrintWriter out = new PrintWriter (socket.getoutputstream()); String response = " Hello " + request+ "!"; out.println (response ); out.flush (); } catch (IOException e) { System.err.println("Eroare IO \n" + e); } finally { try { socket.close(); } catch ( IOException e) { System.err. println (e); } }}} 10

11 TCP Client public class SimpleClient { public static void main (String[] args) throws IOException { Socket socket = null ; PrintWriter out = null ; BufferedReader in = null ; try { socket = new Socket (" ", 8080); out = new PrintWriter (socket.getoutputstream(), true); out.println ( Vlad ); out.close(); in = new BufferedReader ( new }} InputStreamReader(socket.getInputStream ())); raspuns = in.readline (); in.close(); } catch ( UnknownHostException e) { System.err.println (e); } finally { socket.close(); } 11

12 UPD Server DatagramSocket socket = new DatagramSocket(8200); byte buf[] = new byte[256]; DatgramPacket request = new DatagramPacket(buf, buf.length ); socket.receive(request ); InetAddress clientaddress= request.getaddress(); int clientport= request.getport(); String message= " Hello " + new String(clientPort.getData()); buf = message.getbytes(); DatagramPacket response= new DatagramPacket(buf, buf.length, clientaddress, clientport); socket.send(response); 12

13 UPD Client InetAddress serveraddress= InetAddress.getByName(" "); int serverport = 8200; DatagramSocket socket = new DatagramSocket(); byte buf[] = Vlad".getBytes (); DatagramPacket request = new DatagramPacket(buf, buf.length, serveraddress, serverport); socket.send(request); buf[] = new byte [256]; DatagramPacket response= new DatagramPacket(buf, buf.length ); socket.receive(response); System.out.println(new String(response.getData())); 13

14 Reading URL content try { URL url = new URL ( some_url_address ); InputStream in = url.openstream(); br = new BufferedReader (new InputStreamReader (in)); String linie ; while (( linie = br. readline ())!= null ) { System.out.println (linie); } } catch ( MalformedURLException e) { System. err. println ( You should log this error! ); } finally { if (br!= null) { br. close (); } } 14

15 Connecting to an URL try { URL url = new URL(" URLConnection connection = url.openconnection(); connection.setdooutput(true); OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()); String param = URLEncoder.encode("Duke & World", "UTF-8"); out.write("string=" + param); out.close(); BufferedReader in = new BufferedReader( new InputStreamReader(connection.getInputStream())); String response; while ((response = in.readline())!= null) { System.out.println(response); } in.close(); } catch (Exception e) { System. err. println ( You should log this error! ); } } 15

16 JNDI 16

17 RMI 17

18 Assignments Using Swing, Threads and Networking create a chat application that allows for users to send users to one another For simplicity use a Thread on the client that checks for new messages on the server Create a simple application that reads the content of a site and extracts all the domain related links. Extend the application to recursively follow links and creates a site map. 18

19 THANK YOU! Vlad Costel Ungureanu This is a free course from LearnStuff.ro not for commercial use 19

Networking Basics. network communication.

Networking 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 information

Java Networking (sockets)

Java 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 information

Programare avansată Programare în rețea

Programare avansată Programare în rețea Programare avansată Programare în rețea Protocol Protocol = Mulțime de reguli (convenții) care permit interacțiunea între doi sau mai mulți parteneri Adresă IP java.net.innetaddress Innet4Address (32-bit)

More information

Java Technologies. Lecture VII. Valdas Rapševičius. Vilnius University Faculty of Mathematics and Informatics

Java 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 information

Distributed Programming - Sockets

Distributed 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 information

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary

CPSC 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 information

Lecture 3: Socket Programming

Lecture 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 information

protocols September 15,

protocols  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 information

Previous lecture: threads G51PRG: Introduction to Programming Second semester Lecture 12 URL

Previous 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 information

Assignment 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. 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 information

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Network. 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 information

Verteilte Systeme UE Important Code

Verteilte 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 information

Basic Java Network Programming. CS211 July 30 th, 2001

Basic 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 information

URL Kullanımı Get URL

URL 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 information

Network Programming Benoît Garbinato

Network 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 information

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming

COMP 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 information

Chapter 12. Network Programming

Chapter 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 information

Software Practice 1 - Socket

Software 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 information

Advanced Java Programming. Networking

Advanced 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 information

Input from Files. Buffered Reader

Input 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 information

Java Socket Workshop. July Purpose of this workshop:

Java 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 information

Principles, Models and Applications for Distributed Systems M

Principles, 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 information

JAVA 프로그래밍 II. Lab #7 (Networking) TCP Java Socket. TCP vs UDP 2017 학년도 1 학기 년봄학기 5/24/2017 박경신. Client. Server

JAVA 프로그래밍 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 information

Unit 1 Java Networking

Unit 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 information

Java 6. Network programming

Java 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 information

CS September 2017

CS 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 information

Lab 1 : Java Sockets

Lab 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 information

Socket 101 Excerpt from Network Programming

Socket 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 information

Lecture 11.1 I/O Streams

Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 1 OBJECT ORIENTED PROGRAMMING Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 2 Outline I/O Basics Streams Reading characters and string 21/04/2014 Ebtsam AbdelHakam

More information

Networking in Java. Java Fundamentals. Dmitri Gabbasov Tartu 2016

Networking in Java. Java Fundamentals. Dmitri Gabbasov Tartu 2016 Networking in Java Java Fundamentals Dmitri Gabbasov Tartu 2016 The java.net package java.net.socket represents a TCP connection to a remote endpoint java.net.serversocket represents a TCP endpoint that

More information

Java Programming Language Advance Feature

Java 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 information

CS193j, Stanford Handout #26. Files and Streams

CS193j, 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 information

I/O Streams. Object-oriented programming

I/O Streams. Object-oriented programming I/O Streams Object-oriented programming Outline Concepts of Data Streams Streams and Files File class Text file Binary file (primitive data, object) Readings: GT, Ch. 12 I/O Streams 2 Data streams Ultimately,

More information

Java for Interfaces and Networks

Java 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 information

Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection)

Java.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 information

CS 351 Design of Large Programs Sockets Example

CS 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 information

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1]));

public 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 information

Multimedia Programming

Multimedia Programming Multimedia Programming Medialogy, 8 th Semester, Aalborg University Wednesday 6 June 2012, 09.00 12.00 Instructions and notes You have 3 hours to complete this examination. Neither written material nor

More information

Internet Technology 2/7/2013

Internet 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 information

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary CPSC 441 Assignment-3 Discussion Department of Computer Science University of Calgary Overview of FastFTP protocol TCP for Initial Handshake Port: 2245 Port: 4576 You may choose any free port >1024 at

More information

Distributed Systems. 3. Access to the Transport Layer. Werner Nutt

Distributed 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 information

BrickNet (cont d) Other Academic Projects

BrickNet (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 information

Transport layer protocols. Lecture 15: Operating Systems and Networks Behzad Bordbar

Transport 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

Pieter van den Hombergh Richard van den Ham. March 17, 2018

Pieter 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 information

JAVA Network API. 2 - Connection-Oriented vs. Connectionless Communication

JAVA 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 information

Java for Interfaces and Networks (DT3029)

Java 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 information

Java for Interfaces and Networks (DT3010, HT11)

Java 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 information

Java A.1 TCP/IP TCP. TCP_RO.java import java.net.*; import java.io.*;

Java 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 information

CS 251 Intermediate Programming Java I/O Streams

CS 251 Intermediate Programming Java I/O Streams CS 251 Intermediate Programming Java I/O Streams Brooke Chenoweth University of New Mexico Spring 2018 Basic Input/Output I/O Streams mostly in java.io package File I/O mostly in java.nio.file package

More information

Principles of Software Construction. Introduction to networks and distributed systems School of Computer Science

Principles 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 information

Network Programming 1

Network Programming 1 Network Programming 1 Network Programming Java and C++ can easily be used for network programming based in the client-server model. The client-server model is probably the most commonly used model for

More information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / 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 information

Introduction to Network Programming using Java

Introduction 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 information

File 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 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 information

Interprocess Communication

Interprocess 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 information

Introduction to Sockets 9/25/14

Introduction 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 information

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket

TCP 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 information

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary

CPSC 441 Assignment-3 Discussion. Department of Computer Science University of Calgary CPSC 441 Assignment-3 Discussion Department of Computer Science University of Calgary Overview of FastFTP protocol TCP for Initial Handshake Port: 1111 Port: 4444 UDP for File Content Transfer Port: 3333

More information

Darshan Institute of Engineering & Technology for Diploma Studies

Darshan 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 information

Objec&ves. Review. Standard Error Streams

Objec&ves. Review. Standard Error Streams Objec&ves Standard Error Streams Ø Byte Streams Ø Text Streams Oct 5, 2016 Sprenkle - CSCI209 1 Review What are benefits of excep&ons What principle of Java do files break if we re not careful? What class

More information

Java networking using sockets

Java networking using sockets Teaching Assistant Andrei Vasilateanu Java networking using sockets Introduction One of the software architectures used in distributed computing is client-server. The server offers a service which is requested

More information

Java for Interfaces and Networks (DT3029)

Java 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 information

Project 0. Danyang Zhuo CSE sp Sec;on #2

Project 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 information

CS 2113 Software Engineering

CS 2113 Software Engineering CS 2113 Software Engineering Java 6: File and Network IO https://github.com/cs2113f18/template-j-6-io.git Professor Tim Wood - The George Washington University Project 2 Zombies Basic GUI interactions

More information

Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming)

Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming) Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming) Medialogy, 4 th Semester, Aalborg Monday 11 June 2012, 09.00 12.00 Instructions You have 3 hours to complete

More information

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis

Multi-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 information

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003 Input, Output and Exceptions COMS W1007 Introduction to Computer Science Christopher Conway 24 June 2003 Input vs. Output We define input and output from the perspective of the programmer. Input is data

More information

IT101. File Input and Output

IT101. 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 information

PIC 20A Streams and I/O

PIC 20A Streams and I/O PIC 20A Streams and I/O Ernest Ryu UCLA Mathematics Last edited: December 7, 2017 Why streams? Often, you want to do I/O without paying attention to where you are reading from or writing to. You can read

More information

Networking Code CSCI 201 Principles of Software Development

Networking 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 information

CSCD 330 Network Programming Spring 2018

CSCD 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 information

Today. cisc3120-fall2012-parsons-lectiv.2 2

Today. 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 information

Java Development: Do s and Don ts

Java Development: Do s and Don ts Java Development: Do s and Don ts 1 Overview Asynchronous networking Data copies Connection management Logging 2 ASL Project 2016: Middleware for different replication modes Middleware op SET/DEL GET Memcached

More information

CSCD 330 Network Programming Winter 2019

CSCD 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 information

31 Network Programming

31 Network Programming 31 Network Programming Network / Inter-Network OODS 1997-2000 Michael Golm Network Programming 31.218 31.1 Host Addressing: InetAddress IP addresses: DNS form: www4.informatik.uni-erlangen.de "dotted quad"

More information

Networking and Security

Networking 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 information

CSCD 330 Network Programming Spring 2018

CSCD 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 information

CS 5010: PDP. Lecture 11: Networks CS 5010 Fall 2017 Seattle. Adrienne Slaughter, Ph.D.

CS 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 information

Example: Copying the contents of a file

Example: Copying the contents of a file Administrivia Assignment #4 is due imminently Due Thursday April 8, 10:00pm no late assignments will be accepted Sign up in the front office for a demo time Dining Philosophers code is online www.cs.ubc.ca/~norm/211/2009w2/index.html

More information

Introduction to Sockets

Introduction 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 information

Socket Programming(TCP & UDP) Sanjay Chakraborty

Socket 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 information

Reading from URL. Intent - open URL get an input stream on the connection, and read from the input stream.

Reading 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 information

Reliability is an issue. You cannot afford to have any of the data lost or re-ordered.

Reliability is an issue. You cannot afford to have any of the data lost or re-ordered. Appendix C Socket Programming C.1 Socket Programming in Java C.1.1 Networking Basics Computers running on the Internet communicate to each other using the Internet Protocol (IP). Usually the Transmission

More information

"protocol stack! chat. Java

protocol stack! chat. Java "protocol stack! chat # # $ "! $ http://www.ietf.org/rfc.html http://www.skype.com$ Internet for dummies "' &! ("IP Address! %%() "port! * +%#%%() * * % * (I/O "streams! InputStreamReader in = new InputStreamReader(System.in);

More information

CPSC 441 UDP Socket Programming. Department of Computer Science University of Calgary

CPSC 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 information

Chapter 2 Applications and

Chapter 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 information

Byte and Character Streams. Reading and Writing Console input and output

Byte 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 information

JAVA SOCKET PROGRAMMING

JAVA 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 information

CSS 533 Program 2: Distributed Java Space Servers Professor: Munehiro Fukuda Due date: see the syllabus

CSS 533 Program 2: Distributed Java Space Servers Professor: Munehiro Fukuda Due date: see the syllabus CSS 533 Program 2: Distributed Java Space Servers Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment implements a collection of distributed Java Space servers, which exercises

More information

Basic Java IO Decorator pattern Advanced Java IO. Java IO - part 2 BIU OOP. BIU OOP Java IO - part 2

Basic Java IO Decorator pattern Advanced Java IO. Java IO - part 2 BIU OOP. BIU OOP Java IO - part 2 Java IO - part 2 BIU OOP Table of contents 1 Basic Java IO What do we know so far? What s next? 2 Example Overview General structure 3 Stream Decorators Serialization What do we know so far? What s next?

More information

Distributed Programming

Distributed Programming Distributed Programming Processes don t share memory. Processes share channels over which messages are passed Channels may be Global, receiver specific, or sender & receiver specific. One or two way. c

More information

Networking SYSTEM SOFTWARE 1

Networking SYSTEM SOFTWARE 1 Networking SYSTEM SOFTWARE 1 Networking Introduction Sockets ServerSockets URL and URLConnection Summary SYSTEM SOFTWARE 2 Network Programming Writing programs where different components are executed on

More information

Lecture 4: Exceptions. I/O

Lecture 4: Exceptions. I/O Lecture 4: Exceptions. I/O Outline Access control. Class scope Exceptions I/O public class Malicious { public static void main(string[] args) { maliciousmethod(new CreditCard()); } static void maliciousmethod(creditcard

More information

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005.

Sockets and RMI. CS151 Chris Pollett Dec. 5, 2005. Sockets and RMI CS151 Chris Pollett Dec. 5, 2005. Outline Echo Server with Multiple Clients Client pull/server push Remote Method Invocation Proxy Pattern Echo Server with Multiple Clients public class

More information

Info 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub

Info 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 information

Networking. Lecture 25 ish? COP 3252 Summer July 11, 2017

Networking. 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 information

1.00 Lecture 30. Sending information to a Java program

1.00 Lecture 30. Sending information to a Java program 1.00 Lecture 30 Input/Output Introduction to Streams Reading for next time: Big Java 15.5-15.7 Sending information to a Java program So far: use a GUI limited to specific interaction with user sometimes

More information

Chapter 9: UDP sockets & address conversion function

Chapter 9: UDP sockets & address conversion function Chapter 9: UDP sockets & address conversion function 9.1 Elementary UDP sockets:- Introduction to UDP sockets UDP is connectionless, unreliable, datagram protocol TCP is connection-oriented, reliable byte

More information

Introduction Unit 4: Input, output and exceptions

Introduction Unit 4: Input, output and exceptions Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Introduction Unit 4: Input, output and exceptions 1 1.

More information

Project 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 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 information