CISC 4700 L01 Network & Client-Server Programming Spring Harold, Chapter 4: Internet Addresses
|
|
- Shonda Burns
- 5 years ago
- Views:
Transcription
1 CISC 4700 L01 Network & Client-Server Programming Spring 2016 Harold, Chapter 4: Internet Addresses
2 IPv4 address: four bytes ( ) IPv6 address: sixteen bytes (2001:0250:02FF:0210:0250:8BFF:FEDE:67C8) DNS: mechanism for translating back and forth between IP addresses in dotted quad form and hostnames erdos.dsm.fordham.edu 2400:cb00:2048:1:0:0:6ca2:c Previous mechanism: centrally located HOSTS.TXT file Some hosts have multiple names (e.g., the "www" and "ftp" conventions). Some have multiple IP addresses (e.g., on two networks) erdos.dsm.fordham.edu Std DNS software package: BIND, which includes named and the like. Configuring DNS: a major pain. Rather than each host running BIND software, it has access to one or more nameservers (specified in the /etc/resolv.conf file in the Unix world).
3 The InetAddress Class (in the java.net package) Encapsulates Internet address.... extends java.lang.object... final class (can't be subclassed) Used by other networking classes (Socket, ServerSocket, URL,... ). Internally represents Internet address as String hostname and int address. These fields have package visibility; they may be accessed via getters and setters. Creating New InetAddress Objects No public ctors!! Assuming import java.net.*; use factory methods InetAddress address = InetAddress.getByName(" or InetAddress address = InetAddress.getByAddress(" ");
4 The tostring() method produces a representation hostname/dotted quad, thus: String dottedquadaddress = " "; try { InetAddress address = InetAddress.getByName(dottedQuadAddress); System.out.println(address); catch (UnknownHostException e) { System.out.println("Could not find " + dottedquadaddress); would print sobolev.dsm.fordham.edu/ when run. Note: getbyname doesn't do DNS lookup. This only happens when DNS lookup is actually required (implicit or explicit). Hence can create InetAddress objects for non-existent hosts.
5 getallbyname: used to get *all* Internet addresses. String hostname=" try { InetAddress[] addresses = InetAddress.getAllByName(hostName); for (int i = 0; i < addresses.length; i++) { System.out.println(addresses[i]); catch (UnknownHostException e) { System.out.println("Could not find " + hostname); getlocalhost: find address of local machine try { InetAddress address = InetAddress.getLocalHost(); System.out.println(address); catch (UnknownHostException e) { System.out.println("Could not find computer's address.");
6 Caching Purpose: save time (IP address shouldn t change while app is running.) Java only caches negative results for 10 seconds (reconfigurable). Java can t control non-local caching (e.g., DNS server). Security Issues Main idea: an untrusted applet can't perform arbitrary DNS lookups for third-party hosts, since Evil Ones can use this to set up a covert channel allowing applet to talk to a third party. Example: Applet downloaded from wants to send msg " is vulnerable" to evilgenius.org. Applet only needs to create DNS request " This fails, but the msg appears in the evilgenius.org DNS error log. See pp for further discussion.
7 Getter Methods gethostname(), gethostaddress(): return hostname or dotted quad address of IP address represented by an InetAddress object. String dottedquadaddress = " "; try { InetAddress ia = InetAddress.getByName(dottedQuadAddress); System.out.println(ia.getHostName()); catch (Exception e) { System.err.println(e); prints sobolev.dsm.fordham.edu when run try { InetAddress me = InetAddress.getLocalHost(); String dottedquad = me.gethostaddress(); System.out.println("My address is " + dottedquad); catch (UnknownHostException e) { System.out.println("I don't know my own address."); prints
8 getaddress(): returns IP address as 4-byte (IPv4) or 16-byte (IPv6) array of byte. One might think that this is OK: try { InetAddress me = InetAddress.getLocalHost(); byte address[] = me.getaddress(); System.out.print("My IP address: "); for (int i = 0; i < 4; i++) { System.out.print((int)address[i]); if (i < address.length - 1) System.out.print("."); System.out.println(); catch (UnknownHostException ex) { System.err.println(ex); It implicitly assumes IPv4. What about IPv6? Also, when run, this produces My IP address:
9 Let s write the following useful helper functions: public class AddressTests { public static int getversion(inetaddress ia) { byte[] address == ia.getaddress(); if (address.length == 4) return 4; if (address.length == 1) return 6; return -1; public static char getseparator(inetaddress ia){ int version = getversion(ia); if (version == 4) return : ; if (version == 6) return : ; return? ;
10 Problem? bytes in the IP address are unsigned, in the range Unlike C, Java doesn't have an unsigned byte type. So bytes in the range are treated as negative numbers; you need to add 256 to them to get the proper values: InetAddress me = InetAddress.getLocalHost(); byte address[] = me.getaddress(); char separator = AddressTests.getSeparator(me); System.out.print("My IP address: "); for (int i = 0; i < address.length; i++) { int thebyte = (int)address[i]; if (thebyte < 0) thebyte += 256; System.out.print(theByte); if (i < address.length - 1) System.out.print(separator); System.out.println(); When run, this produces My IP address: as expected.
11 More useful: determining the class (A, B, C, D, E) of an IPv4 address. Here, class A addresses begin with 0 network: bits 1-7 of byte 0; host: bytes 1-3 class B addresses begin with 10 network: bits 2-7 of byte 0, with byte 1; host: bytes 2-3 class C addresses begin with 110 network: bits 3-7 of byte 0, with bytes 1 and 2; host: byte 3 class D addresses begin with 1110 multicast group: bits 4-7 of byte 0, with bytes 1-3 class E addresses begin with bits 5-7 of byte 0, with bytes 1-3, are reserved for future use public static char getclass(inetaddress ia) { byte[] address = ia.getaddress(); int firstbyte = address[0]; if ((firstbyte & 0x80) == 0) return 'A'; else if ((firstbyte & 0xC0) == 0x80) return 'B'; else if ((firstbyte & 0xE0) == 0xC0) return 'C'; else if ((firstbyte & 0xF0) == 0xE0) return 'D'; else if ((firstbyte & 0xF8) == 0xF0) return 'E'; else return 'F';
12 Address Types In Java public boolean isanylocaladdress() public boolean isloopbackaddress() public boolean islinklocaladdress() public boolean issitelocaladdress() public boolean ismulticastaddress() public boolean ismcglobal() public boolean ismcorglocal() public boolean ismcsitelocal() public boolean ismclinklocal() public boolean ismcnodeocal() Sample program: test characteristics of an IP address import java.net.*; public class IPCharacteristics { public static void main(string[] args) { try { InetAddress address = InetAddress.getByName(args[0]);
13 if (address.isanylocaladdress()) { System.out.println(address + " is a wildcard address."); if (address.isloopbackaddress()) { System.out.println(address + " is loopback address."); if (address.islinklocaladdress()) { System.out.println(address + " is a link-local address."); else if (address.issitelocaladdress()) { System.out.println(address + " is a site-local address."); else { System.out.println(address + " is a global address.");
14 if (address.ismulticastaddress()) { if (address.ismcglobal()) { System.out.println(address + " is a global multicast address."); else if (address.ismcorglocal()) { System.out.println(address + " is an organization wide multicast address."); else if (address.ismcsitelocal()) { System.out.println(address + " is a site wide multicast address."); else if (address.ismclinklocal()) { System.out.println(address + " is a subnet wide multicast address."); else if (address.ismcnodelocal()) { System.out.println(address + " is an interface-local multicast address."); else { System.out.println(address + " is an unknown multicast address type.");
15 else { System.out.println(address + " is a unicast address."); catch (UnknownHostException ex) { System.err.println("Could not resolve " + args[0]);
16 Testing Reachability Check to see whether a host is reachable: public boolean isreachable(int timeout) throws IOException public boolean isreachable(networkinterface interface, int ttl, int timeout) throws IOException Attempts to connect to remote host's echo port. Object Methods InetAddress inherits from java.lang.object. It overrides three methods from Object: equals(): an object o equals an InetAddress object ia iff o is an InetAddress object o and ia have same IP address hashcode(): returns four bytes of the address, converted to an int tostring(): returns host name/dotted quad address if no name, then dotted quad/dotted quad
17 Example: Test to see whether or not two hostnames are the same import java.net.*; public class AreAliases { public static void main (String args[]) { if (args.length!= 2) { System.err.println("Usage: AreAliases address1 address2"); System.exit(1); try { InetAddress address0 = InetAddress.getByName(args[0]); InetAddress address1 = InetAddress.getByName(args[1]); System.out.print(args[0] + " is "); if (!address0.equals(address1)) System.out.print("not "); System.out.println("the same as " + args[1]); catch (UnknownHostException e) { System.out.println("Host lookup failed.");
18 Inet4Address and Inet6Address Subclasses of InetAddress. Generally, app program shouldn't care whether an IP address is IPv4 or IPv6. Inet4Address overrides several methods in InetAddress, but doesn t change their behavior in any significant way. Inet6Address has one new method not found in InetAddress: public boolean isipv4address() If true, address has form ::xxxx, can create new InetAddress object from last four bytes of array returned by getbytes().
19 NetworkInterface Class Represents local IP address (physical or virtual). Factory methods public static NetworkInterface getbyname(string name) throws SocketException Returns NetworkInterface object representing network interface with this name (or null, if no such) Typical names: Unix: "eth0", "em1", "enp5s0f1" ; "lo" Windows: "CE31", "ELX100" try { NetworkInterface ni = new NetworkInterface.getByName("eth0"); if (ni == null) System.err.println("No such interface: eth0"); catch (SocketException ex) { System.err.println("Could not list sockets");
20 public static NetworkInterface getbyaddress (InetAddress address)throws SocketException Returns NetworkInterface object representing network interface bound to given IP address (or null, if no such) Example: Find network interface for local loopback address try { InetAddress local = InetAddress.getByName(" "); NetworkInterface ni = NetworkInterface.getByInetAddress(local); if (ni == null) { System.err.println( "That's weird. No local loopback address."); catch (SocketException ex) { System.err.println("Could not list sockets."); catch (UnknownHostException ex) { System.err.println( "That's weird. No local loopback address.");
21 public static Enumeration getnetworkinterfaces() throws SocketException Returns java.util.enumeration listing all network interfaces on local host. Example: List all network interfaces on local host import java.net.*; import java.util.*; public class InterfaceLister { public static void main(string[] args) throws Exception { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasmoreelements()) { NetworkInterface ni = interfaces.nextelement(); System.out.println(ni);
22 When run on sobolev.dsm.fordham.edu: $ java InterfaceLister name:em1 (eth0) name:lo (lo) When run on erdos.dsm.fordham.edu: $ java InterfaceLister name:enp5s0f0(enp5s0f0) name:enp7s0 (enps70) name:lo (lo)
23 Getter Methods public Enumeration getinetaddresses() returns Enumeration of all IP addresses associated with the interface (usually only one, sometimes more than one) Example: NetworkInterface em1 = NetworkInterface.getByName("em1"); Enumeration addresses = em1.getinetaddresses(); while (addresses.hasmoreelements()) System.out.println(addresses.nextElement()); Output when run on sobolev.dsm.fordham.edu: /fe80:0:0:0:ea39:35ff:fe49:cde2%2 / public String getname() returns name of a NetworkInterface object (e.g., "em1") public String getdisplayname() supposedly returns more human-friendly name for NetworkInterface
24 Some Useful Programs SpamCheck Real-time blackhole lists (RTBLs): monitor spammers For example: sbl.spamhaus.org To identify whether a given IP address is a spammer: reverse the bytes in IP address prepend this to sbl.spamhaus.org do a DNS lookup this succeeds iff the IP address is listed as a spammer So to check , do a DNS lookup on sbl.spamhaus.org sobolev@dsm:src$ nslookup sbl.spamhaus.org Server: Address: #53 ** server can't find sbl.spamhaus.org: NXDOMAIN Look at
25 HostLookup nslookup is a Unix utility that does hostanme <-> IP address conversion: $ nslookup sobolev.dsm.fordham.edu Server: Address: #3 Name: sobolev.dsm.fordham.edu Address: $ nslookup > sobolev.dsm.fordham.edu Server: Address: #3 Name: sobolev.dsm.fordham.edu Address: > (typed control-d here) See
26 Processing Web Server Log Files A web server log file contains lines such as [15/Feb/2001:09:40: ] "GET / HTTP 1.0" where the fields are remotehost: usually in dotted quad form rfc931 specification of user on remote system (usually a dash) authuser: authenticated remote username (usually a dash) [date] "HTTP request" status bytes sent It would be nicer if the remotehost were a hostname. That's what the Weblog application does. It takes one command line parameter (the name of the web server log file) and prints each line in the logfile, with each IP address replaced by a hostname.
27 Pseudocode: bin = BufferedReader built from args[0]; entry = null string; // needed to get the loop started for (String entry = bin.readline(); entry!= null; entry = bin.readline()) { break entry into ip (IP address) and therest (everything else); find the hostname; print hostname and therest; See
28 Author suggests threading to improve performance. But first, a detour... ThreadPools (from Chapter 3 of Harold): Adding additional threads to a program can improve performance. But threads have their own overhead: starting thread cleanup when thread dies cost of switching between (CPU-bound) threads Java can let you use a pool of reusable worker threads. Executors class (in java.util.concurrent): makes it easy to set up a thread pool: Submit each task as a Runnable or Callable object to the pool. A Callable can have a return value, returned by its call() method. Get back a Future object, which you can use to check progress of task.
29 Example: Find the largest element in an array of integers, by splitting the work into two threads (may be faster on multiple-core chip). import java.util.concurrent.callable; class FindMaxTask implements Callable<Integer> { private int[] data; private int start; private int end; FindMaxTask(int[] data, int start, int end) { this.data = data; this.start = start; this.end = end; public Integer call() { int max = Integer.MIN_VALUE; for (int i = start; i < end; i++) { if (data[i] > max) max = data[i]; 2 9
30 import java.util.concurrent.*; public class MultithreadedMaxFinder { public static int max(int[] data) throws InterruptedException, ExecutionException { if (data.length == 1) { return data[0]; else if (data.length == 0) { throw new IllegalArgumentException(); // split the job into 2 pieces FindMaxTask task1 = new FindMaxTask(data, 0, data.length/2); FindMaxTask task2 = new FindMaxTask(data, data.length/2, data.length); // spawn 2 threads ExecutorService service = Executors.newFixedThreadPool(2); Future<Integer> future1 = service.submit(task1); Future<Integer> future2 = service.submit(task2); return Math.max(future1.get(), future2.get()); 3 0
31 Code at My own experiment (logfile with around 350,000 entries): time java Weblog ~/tmp/ssl_access_log > /dev/null real 0m59.291s user 0m1.662s sys 0m0.213s time java PooledWeblog ~/tmp/ssl_access_log > /dev/null real 0m49.902s user 0m3.857s sys 0m0.355s 3 1
Ch.4 Internet Addresses
CSB541 Network Programming 網路程式設計 Ch.4 Internet Addresses 吳俊興國立高雄大學資訊工程學系 Outline 4.1 The InetAddress Class 4.2 Inet4Address and Inet6Address 4.3 The NetworkInterface Class 4.4 Some Useful Programs 2 Internet
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 informationLesson: Programmatic Access to Network Parameters
Lesson: Programmatic Access to Network Parameters Systems often run with multiple active network connections, such as wired Ethernet, 802.11 b/g (wireless), and bluetooth. Some applications might need
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 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 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 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 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 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 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 informationAJP: Chapter 2 Networking: 18 marks
AJP: Chapter 2 Networking: 18 marks Syllabus 2.1 Basics Socket overview, client/server, reserved sockets, proxy servers, internet addressing. 2.2 Java & the Net The networking classes & interfaces 2.3
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 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 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 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 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 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 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 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 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 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 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 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 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 informationChair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: concurrency Outline Java threads thread implementation sleep, interrupt, and join threads that return values Thread synchronization
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 8 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ How many partners can we cave for project:
More information31 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 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 information[module lab 1.2] STRUCTURING PROGRAMS IN TASKS
v1.0 Sistemi Concorrenti e di Rete LS II Facoltà di Ingegneria - Cesena a.a 2008/2009 [module lab 1.2] STRUCTURING PROGRAMS IN TASKS 1 STRUCTURING CONCURRENT PROGRAMS INTO TASKS Task concept abstract,
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 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 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 informationNetworking Fundamentals
Networking Fundamentals How Computers Talk to Each Other Fundamentals of Communication Computers need to be told everything in intimate detail because they are dumb. We want to make computers talk to each
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 informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
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 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 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 information830512@itri.org.tw import java.net.socket; import java.net.serversocket; import java.io.ioexception; /* ---------- Java Server ---------- */ public class Nets static Socket thesocket; static ServerThread
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 informationAdvanced Programming Methods. Lecture 6 - Concurrency in Java (1)
Advanced Programming Methods Lecture 6 - Concurrency in Java (1) Overview Introduction Java threads Java.util.concurrent References NOTE: The slides are based on the following free tutorials. You may want
More informationCompletable Future. Srinivasan Raghavan Senior Member of Technical Staff Java Platform Group
Completable Future Srinivasan Raghavan Senior Member of Technical Staff Java Platform Group Program Agenda 1 2 3 4 java.util.future Introduction Cloud Services Design and the fight for Performance CompletableFuture
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 informationMultiplayer Game Programming 2/26
Multiplayer Game Programming 2/26 1. Turn off Windows Firewall 2. Download and install Python and Notepad++ a. Python.org downloads/python/install b. Notepad-plus-plus.org download/install 3. Download
More informationHighlights of Last Week
Highlights of Last Week Refactoring classes to reduce coupling Passing Object references to reduce exposure of implementation Exception handling Defining/Using application specific Exception types 1 Sample
More informationLecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University
Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types
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 informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2018 Lecture 7 Threads Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ How many processes can a core
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 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 informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 11
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 11 EXCEPTION HANDLING Many higher-level languages provide exception handling Concept: One part of the program knows how to detect a problem,
More informationSystem Programming. Practical Session 4: Threads and Concurrency / Safety
System Programming Practical Session 4: Threads and Concurrency / Safety Using Threads - All the computer programs you've seen so far were sequential only one thing was performed at any given time - Sometimes
More informationCHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA
1. JIT meaning a. java in time b. just in time c. join in time d. none of above CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA 2. After the compilation of the java source code, which file is created
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 informationI pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.
Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone
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 informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationCSCI 201L Written Exam #1 Fall % of course grade
Final Score /15 Name SOLUTION ID Extra Credit /0.5 Lecture Section (circle one): TTh 8:00-9:20 TTh 9:30-10:50 TTh 11:00-12:20 CSCI 201L Written Exam #1 Fall 2017 15% of course grade The exam is one hour
More informationFinal Concurrency. Oleg October 27, 2014
Final Concurrency Oleg Šelajev @shelajev oleg@zeroturnaround.com October 27, 2014 Feedbacks Task Executors Fork-Join framework Completable Future Agenda 2 HOMEWORK 4 FEEDBACK THREAD LOCAL VARIABLES TASK
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 informationThreads Chate Patanothai
Threads Chate Patanothai Objectives Knowing thread: 3W1H Create separate threads Control the execution of a thread Communicate between threads Protect shared data C. Patanothai Threads 2 What are threads?
More informationBrief Summary of Java
Brief Summary of Java Java programs are compiled into an intermediate format, known as bytecode, and then run through an interpreter that executes in a Java Virtual Machine (JVM). The basic syntax of Java
More information1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void
1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void addtemperaturelistener ( TemperatureListener listener ) 5 throws
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 informationLanguage Features. 1. The primitive types int, double, and boolean are part of the AP
Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are
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 informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationMultiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)
M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but
More informationMajustic - Evaluation Test With Answers. Time: 1 hour 30 minutes
Majustic - Evaluation Test With Answers Time: 1 hour 30 minutes Version 1.0, 04/07/2015 Summary 1. JAVA Questions.............................................................................. 1 1.1. Consider
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 informationScheme G Sample Question Paper Unit Test 2
Scheme G Sample Question Paper Unit Test 2 Course Name: Computer Engineering Group Course Code: CO/CD/CM/CW/IF Semester: Sixth Subject Title: Advanced Java Programming Marks: 25 Marks 17625 ---------------------------------------------------------------------------------------------------------------------------
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 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 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 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 informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2019 Lecture 7 Threads Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Amdahls law example: Person
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 informationChapter 27 Cluster Work Queues
Chapter 27 Cluster Work Queues Part I. Preliminaries Part II. Tightly Coupled Multicore Part III. Loosely Coupled Cluster Chapter 18. Massively Parallel Chapter 19. Hybrid Parallel Chapter 20. Tuple Space
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationCSEN 202 Introduction to Computer Programming
CSEN 202 Introduction to Computer Programming Lecture 4: Iterations Prof. Dr. Slim Abdennadher and Dr Mohammed Abdel Megeed Salem, slim.abdennadher@guc.edu.eg German University Cairo, Department of Media
More information/* Copyright 2012 Robert C. Ilardi
/ Copyright 2012 Robert C. Ilardi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
More informationCS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 11
CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2015 Lecture 11 EXCEPTION HANDLING! Many higher-level languages provide exception handling! Concept: One part of the program knows how to detect a problem,
More informationJava: advanced object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Packages
More informationInternet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 2004
Internet and Intranet Applications and Protocols Examples of Bad SMTP Code Prof. Arthur P. Goldberg Spring, 00 Summary I show some examples of bad code and discuss how they fail to meet the Software Quality
More informationCS11 Java. Fall Lecture 4
CS11 Java Fall 2014-2015 Lecture 4 Java File Objects! Java represents files with java.io.file class " Can represent either absolute or relative paths! Absolute paths start at the root directory of the
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 informationCONCURRENCY IN JAVA Course Parallel Computing
CONCURRENCY IN JAVA Course Parallel Computing Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Wolfgang.Schreiner@risc.jku.at http://www.risc.jku.at Java on a NUMA Architecture Loading
More informationJAVA EXAMPLES - SOLVING DEADLOCK
JAVA EXAMPLES - SOLVING DEADLOCK http://www.tutorialspoint.com/javaexamples/thread_deadlock.htm Copyright tutorialspoint.com Problem Description: How to solve deadlock using thread? Solution: Following
More informationSockets: Network io HOM DOS HVD HEE. Sockets, Object Streams and Serialization. Sockets. Sockets: Network io HOM DOS HVD HEE
: Network : Network ieter van den Hombergh hijs Dorssers ichard van den Ham Uwe van Heesch, bject Fontys Hogeschool voor echniek en Logistiek April 22, 2016 /FHenL : Network April 22, 2016 1/19 opics :
More informationPRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 10. PUTTING IT ALL TOGETHER. Are we there yet?
PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 10. PUTTING IT ALL TOGETHER Are we there yet? Developing software, OOA&D style You ve got a lot of new tools, techniques, and ideas about how to develop
More informationJava Bytecode (binary file)
Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.
More informationI gave this assignment in my Internet and Intranet Protocols and Applications course:
Producing Production Quality Software Lecture 1b: Examples of Bad Code Prof. Arthur P. Goldberg Fall, 2004 Summary I show some examples of bad code and discuss how they fail to meet the Software Quality
More informationIslamic University of Gaza Faculty of Engineering Computer Engineering Department
Student Mark Islamic University of Gaza Faculty of Engineering Computer Engineering Department Question # 1 / 18 Question # / 1 Total ( 0 ) Student Information ID Name Answer keys Sector A B C D E A B
More informationC16b: Exception Handling
CISC 3120 C16b: Exception Handling Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/28/2018 CUNY Brooklyn College 1 Outline Exceptions Catch and handle exceptions (try/catch)
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 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 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 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 informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More information