Multiplayer Game Programming 2/26
|
|
- Martha Parker
- 5 years ago
- Views:
Transcription
1 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 and run TCPView. a. Go to the web page b. Click Downloads, click Networking Utilities, and click TCPView. c. Download the zip file and unzip. d. Create a new folder named sysinternals. e. Unzip the TCPView program and copy it into the sysinternals folder. f. Run TCPView. 4. TCP and UDP Connections TCP slower but guarantees delivery UDP faster but no guarantee of delivery 5. Clients and Servers find each other by IP addresses 6. Applications work on Port numbers Connect to Address using Port Web uses port Well known ports Registered Ports Basic Client and Server program logic: a. Server i. Start and listen on port for incoming connection - loop ii. Client sends request to talk to server iii. Server opens connection and starts sending/receiving to client based on protocol b. Client i. Send request packet to Server on specified port ii. Waits for server to respond with port connection (packet level) iii. Starts talking to server based on protocol
2 8. Problems with basic program logic a. Maintaining multiple client connections to Server b. Blocking Port Server opens and then blocks the port from other connections while it waits for the client to send/receive data. 9. One way to solve the blocking operation is to use Threads. Each connection is started on its own thread and the server operations handle a multi-threaded conversation. (Threads are lightweight Processes) Threads share memory/storage while Processes are operating system based and do not (by default) share memory and interrupt space. (Pipelines can be created between processes). There are several problems with multithreading in large games. Creating and maintaining threads is expensive in terms of resources and parallel threads must be kept in sync. 10. Another way is using the socket non-blocking mode. When a socket is set to non-blocking mode the socket returns an error code if there is nothing to be done and returns the data when there is something there. In this way the server program and store the connections to a data structure (array) and then inside each game loop look at the socket and see if there is incoming data.
3 11. Using Eclipse a. Eclipse is a project oriented development environment. b. Click File/New/Project c. Choose Java/Java Project d. Click next. e. In the Project 12. Adding Python to Eclipse a. Click Help and choose Install New Software b. In Works with type c. Click PyDev check box and install. You may be asked for accept various options. d. Click Window/ Preferences. e. Set the following settings
4 You need to make sure that the Python Interpreter points to python.
5 13. Basic Java Project a. Start Eclipse and close Welcome Window b. Click File/New/Project. You see the project window. c. Click Next. You see the Project setting dialog box d. For the Project Name type JavaTestOne and click the Finish button. This creates a folder in the Eclipse workspace area with this project name. e. Don t create a Java Module. f. If asked, switch to the Java Perspective g. In the left window you see the Package Explorer and the project just created.
6 h. Right click the Project icon, select New, and select Class
7 i. In the Window dialog enter the class name JavaTestClass and click the main check box j. Click Finish to create the class. You now have a basic main class in your project. 14. Importing Libraries a. Java has a set of Java Libraries that provide basic functionality. When writing code you want to import and use these libraries. This can be done automatically in Eclipse. b. Create a new Java Project and add a basic Java Class with a main(). c. Above the line with public static void main and below the line with public class type: Scanner kbd; d. You see the word Scanner underlined in red. This means that this library has not been imported.
8 e. Move the mouse over the word Scanner. You see a popup f. Click the Import Scanner (java.util) link to automatically import this library. g. Below the line with public static void main type: kbd = new Scanner(System.in) notice that kbd is underlined. h. Move the mouse over the underlined kbd and click change kbd to static. 15. Java Exceptions ( a. Java uses and Exception handling architecture to manage errors in code. The purpose of Exceptions is to jump out of loops when an error happens and not to try and cascade errors down through a block of code. Exceptions will jump to the catch part of the exception or (if not caught) jump to the operating system and have it handle the exception. b. Edit your new Java project so it looks like: c. Move the mouse over the File and FileReader words and add the library files. You now have the new FileReader(file) text underlined.
9 d. Using the mouse select the two lines of text you just typed: e. Right click the selected text and choose Surround With and then choose Try/Catch block: f. A try/catch block is now enclosing you code. To check what kind of exception the statement will generate you can move the mouse over the command.
10 The Surround With command looks at the methods being used and automatically figures out what Exception will be thrown. g. Move the mouse over the second FileReader() function. You see the Java documentation for this command: h. Notice that the Throws: option tells you what exception will be thrown.
11 i. Select the try/catch block and remove the File and FileReader lines of code so all you have is: 16. Java Threading a. One way to handle client connections is with a Java Threading server. This will create a new thread for each client connection. The thread will handle input and output with the client. 17. Java Threading Example: a. Edit your project code so it looks like: import java.util.scanner; public class JavaTestClass { static Scanner kbd; public static void main(string[] args) { // TODO Auto-generated method stub kbd = new Scanner(System.in); MyThreadClass c1 = new MyThreadClass("Frank", 5000); MyThreadClass c2 = new MyThreadClass("Donna", 8000); c1.start(); c2.start(); while (true) { if( c1.getnumlives() == 0 && c2.getnumlives()==0) break;
12 System.out.println("What is your name?"); String n = kbd.next(); System.out.println("Hello "+n); System.out.println("All done"); class MyThreadClass extends Thread { private String name; private int pausenum; private int numlives; public MyThreadClass(String n, int p) { name = n; pausenum = p; numlives = 10; public int getnumlives() { return numlives; public void run() { while (numlives > 0) { System.out.println("Hello: I am " + name); numlives--; try { Thread.sleep(pausenum); catch (InterruptedException e) { e.printstacktrace();
13 b. Run the program. 18. Java Networking Client a. Create a new Java Project named JNetProject. b. Create a new class named myjavaclient. c. Enter the following code: import java.io.*; import java.net.*; import java.util.scanner; public class myjavaclient { private static Scanner kbd; public static void main(string[] args) { // TODO Auto-generated method stub kbd = new Scanner(System.in); if(args.length!=2) { System.out.println("Error: must supply host ip and port"); System.out.println("Example:java -jar myjavaclient<host><port>"); System.exit(0); String hostname = args[0]; String portstr = args[1]; int port = Integer.parseInt(portstr); Socket clientsock=null; try { InetAddress addr = InetAddress.getByName(hostname); System.out.println("Connecting..."); clientsock = new Socket(addr,port); // wait for connection System.out.println("Connected"); // get buffers PrintWriter out = new PrintWriter(clientsock.getOutputStream(),true); BufferedReader in = new BufferedReader(new InputStreamReader(clientsock.getInputStream())); // go into write loop boolean stoptalking = false; while(stoptalking==false) { String msgin; String msout; System.out.print("==> "); msgin = kbd.next(); if( msgin.equalsignorecase("stop")) { stoptalking=true; out.println("bye");
14 else { clientsock.close(); continue; out.println(msgin); catch (UnknownHostException e) { // TODO Auto-generated catch block e.printstacktrace(); catch (IOException e) { // TODO Auto-generated catch block e.printstacktrace(); 19. Viewing Socket Connections netstat -an Python Server a. In Eclipse, choose File, choose New, and choose Other.
15 b. In the project window choose PyDev and choose PyDev Project c. Click Next.
16 d. In the PyDev project window set the project name and the interpreter (you must have preciously set the location of the python.exe file). e. Click Finish and change to the python development perspective. f. Right click the pydevserver project, choose New and choose File. g. In the project window make sure you have selected the parent folder (pydevserver). h. For the file name type pydevsrv.py and click Finish. In the Python editor window enter the following code: import socket import sys
17 # check arguments if len(sys.argv)<2: print("must give me IP address and port") host = input("enter your IP address ") port = input("enter your port number ") else: host = sys.argv[1] port = sys.argv[2] try: socket.inet_aton(host) print("ip address looks ok") except socket.error: print("strange IP address "+host+"??? ") sys.exit() try: int(port) print("port looks good") except: print("strange port") sys.exit() # Create a TCP/IP socket sock = socket.socket(socket.af_inet, socket.sock_stream) p = int(port) # Bind the socket to the port sock.bind((host, p)) # Listen for incoming connections sock.listen(1) # Wait for a connection print( "waiting for a connection") connection, client = sock.accept() print (client, "connected") # Receive the data in small chunks and retransmit it
18 cflag=true while(cflag==true): print(cflag) data=connection.recv(1024) d = data.decode('utf-8').strip() if(data): print(d) if(d == "bye"): cflag=false connection.close() sys.exit(1) # Close the connection connection.close() i. Run your program (click the green Run button) j. Enter your computer s IP address and the port number k. Change over to your Java client program and run it. l. Enter the same IP address and the same port number.
Concurrency and Java Programming
Concurrency and Java Programming What is Concurrent Programming? Concurrent programming involves using features of the Java VM that allow parts of your program to run in parallel with each other. This
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 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 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 informationWOSO Source Code (Java)
WOSO 2017 - Source Code (Java) Q 1 - Which of the following is false about String? A. String is immutable. B. String can be created using new operator. C. String is a primary data type. D. None of the
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 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 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 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 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 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 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 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 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 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 informationF I N A L E X A M I N A T I O N
Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student
More informationCSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O
CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O 1 Sending Output to a (Text) File import java.util.scanner; import java.io.*; public class TextFileOutputDemo1 public static void
More informationWhat are Exceptions?
Exception Handling What are Exceptions? The traditional approach Exception handing in Java Standard exceptions in Java Multiple catch handlers Catching multiple exceptions finally block Checked vs unchecked
More informationExceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages
References Exceptions "Handling Errors with Exceptions", Java tutorial http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html CSE 413, Autumn 2005 Programming Languages http://www.cs.washington.edu/education/courses/413/05au/
More informationCS 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 informationICOM 4015-Advanced Programming. Spring Instructor: Dr. Amir H. Chinaei. TAs: Hector Franqui, Jose Garcia, and Antonio Tapia. Reference: Big Java
ICOM 4015-Advanced Programming Spring 2014 Instructor: Dr. Amir H. Chinaei TAs: Hector Franqui, Jose Garcia, and Antonio Tapia Reference: Big Java By Hortsmann, Ed 4 Lab 7 Continuation of HTTP and Introduction
More informationExceptions and Libraries
Exceptions and Libraries RS 9.3, 6.4 Some slides created by Marty Stepp http://www.cs.washington.edu/143/ Edited by Sarah Heckman 1 Exceptions exception: An object representing an error or unusual condition.
More informationExceptions. CSE 142, Summer 2002 Computer Programming 1.
Exceptions CSE 142, Summer 2002 Computer Programming 1 http://www.cs.washington.edu/education/courses/142/02su/ 12-Aug-2002 cse142-19-exceptions 2002 University of Washington 1 Reading Readings and References»
More informationExceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1.
Readings and References Exceptions CSE 142, Summer 2002 Computer Programming 1 http://www.cs.washington.edu/education/courses/142/02su/ Reading» Chapter 18, An Introduction to Programming and Object Oriented
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 informationText User Interfaces. Keyboard IO plus
Text User Interfaces Keyboard IO plus User Interface and Model Model: objects that solve problem at hand. User interface: interacts with user getting input from user giving output to user reporting on
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 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 information1 (6) Lösningsförslag Objektorienterade applikationer Provdatum Program DAI 2 Läsår 2016/2017, lp 3. Uppgift 1 (1+1+1 p) a)
till dugga P r e l i m i n ä r 1 (6) Kursnamn Objektorienterade applikationer Provdatum 2017-02-09 Program DAI 2 Läsår 2016/2017, lp 3 Examinator Uno Holmer Uppgift 1 (1+1+1 p) a) b) c) public interface
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 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 informationCSS 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 informationChapter 2: outline. 2.1 principles of network applications. 2.6 P2P applications 2.7 socket programming with UDP and TCP
Chapter 2: outline 2.1 principles of network applications app architectures app requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail SMTP, POP3, IMAP 2.5 DNS 2.6 P2P applications 2.7 socket programming
More informationEng. Mohammed S. Abdualal
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2124) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 1 Introduction
More informationCOMP-202: Foundations of Programming. Lecture 22: File I/O Jackie Cheung, Winter 2015
COMP-202: Foundations of Programming Lecture 22: File I/O Jackie Cheung, Winter 2015 Announcements Assignment 5 due Tue Mar 31 at 11:59pm Quiz 6 due Tue Apr 7 at 11:59pm 2 Review 1. What is a graph? How
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 informationWorkbook A dialog box will appear asking for you to select your "workspace". Leave the default as is, which should be /home/crsid/workspace.
In this workbook you will learn how to use Eclipse as a development environment for Java programs. Using Eclipse, you will then write a simple Java messaging client which will allow you to send and receive
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 informationCS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling
CS61BL Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling About me Name: Edwin Liao Email: edliao@berkeley.edu Office hours: Thursday 3pm - 5pm Friday 11am - 1pm 611 Soda Or by
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014 Name: This exam consists of 5 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet
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 informationDownloading Tweet Streams and Parsing
and Parsing Ayan Bandyopadhyay IR Lab. CVPR Unit Indian Statistical Institute (Kolkata) To download this slide go to: https://goo.gl/aywi1s 1 and Parsing Downloading Tweet Streams It is imagined that Tweets
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 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 informationChapter 4: Processes
Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems 4.1 Process Concept An operating
More information1. Go to the URL Click on JDK download option
Download and installation of java 1. Go to the URL http://www.oracle.com/technetwork/java/javase/downloads/index.html Click on JDK download option 2. Select the java as per your system type (32 bit/ 64
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 informationCMSC 202. Exceptions
CMSC 202 Exceptions Error Handling In the ideal world, all errors would occur when your code is compiled. That won t happen. Errors which occur when your code is running must be handled by some mechanism
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 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 informationWhen we reach the line "z = x / y" the program crashes with the message:
CSCE A201 Introduction to Exceptions and File I/O An exception is an abnormal condition that occurs during the execution of a program. For example, divisions by zero, accessing an invalid array index,
More informationRecitation: Loop Jul 7, 2008
Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for
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 information3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)
GETTING STARTED: YOUR FIRST JAVA APPLICATION 15 3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS) GETTING STARTED: YOUR FIRST JAVA APPLICATION Checklist: The most recent version of Java SE Development
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 informationSelected Sections of Applied Informatics LABORATORY 0
SSAI 2018Z: Class 1. Basics of Java programming. Page 1 of 6 Selected Sections of Applied Informatics LABORATORY 0 INTRODUCTION TO JAVA PROGRAMMING. BASIC LANGUAGE INSTRUCTIONS. CONSOLE APPLICATION. CONDITION,
More informationVirtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.
1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program
More informationWentworth Institute of Technology. Engineering & Technology WIT COMP1000. File Input and Output
WIT COMP1000 File Input and Output I/O I/O stands for Input/Output So far, we've used a Scanner object based on System.in for all input (from the user's keyboard) and System.out for all output (to the
More informationExceptions and Working with Files
Exceptions and Working with Files Creating your own Exceptions. You have a Party class that creates parties. It contains two fields, the name of the host and the number of guests. But you don t want to
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 informationpublic class Q1 { public int x; public static void main(string[] args) { Q1 a = new Q1(17); Q1 b = new Q1(39); public Q1(int x) { this.
CS 201, Fall 2013 Oct 2nd Exam 1 Name: Question 1. [5 points] What output is printed by the following program (which begins on the left and continues on the right)? public class Q1 { public int x; public
More informationCSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013
CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013 Name: This exam consists of 5 problems on the following 6 pages. You may use your double-sided hand-written 8 ½ x 11 note sheet
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 informationCOMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE. Instructor: Prasun Dewan (FB 150,
COMP 110/401 APPENDIX: INSTALLING AND USING ECLIPSE Instructor: Prasun Dewan (FB 150, dewan@unc.edu) SCOPE: BASICS AND BEYOND Basic use: CS 1 Beyond basic use: CS2 2 DOWNLOAD FROM WWW.ECLIPSE.ORG Get the
More informationFull file at Chapter 2 - Inheritance and Exception Handling
Chapter 2 - Inheritance and Exception Handling TRUE/FALSE 1. The superclass inherits all its properties from the subclass. ANS: F PTS: 1 REF: 76 2. Private members of a superclass can be accessed by a
More informationLecture 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 informationEXCEPTION HANDLING. // code that may throw an exception } catch (ExceptionType parametername) {
EXCEPTION HANDLING We do our best to ensure program correctness through a rigorous testing and debugging process, but that is not enough. To ensure reliability, we must anticipate conditions that could
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 informationGetting Started with Eclipse/Java
Getting Started with Eclipse/Java Overview The Java programming language is based on the Java Virtual Machine. This is a piece of software that Java source code is run through to produce executables. The
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 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 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 informationBBM 102 Introduction to Programming II Spring Exceptions
BBM 102 Introduction to Programming II Spring 2018 Exceptions 1 Today What is an exception? What is exception handling? Keywords of exception handling try catch finally Throwing exceptions throw Custom
More informationSchool of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15
Table of Contents 1 INTRODUCTION... 1 2 IF... 1 2.1 BOOLEAN EXPRESSIONS... 3 2.2 BLOCKS... 3 2.3 IF-ELSE... 4 2.4 NESTING... 5 3 SWITCH (SOMETIMES KNOWN AS CASE )... 6 3.1 A BIT ABOUT BREAK... 7 4 CONDITIONAL
More informationIntroduction to Java. Nihar Ranjan Roy. https://sites.google.com/site/niharranjanroy/
Introduction to Java https://sites.google.com/site/niharranjanroy/ 1 The Java Programming Language According to sun Microsystems java is a 1. Simple 2. Object Oriented 3. Distributed 4. Multithreaded 5.
More informationCSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics
CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics 1 Computer Basics Computer system: hardware + software Hardware: the physical components Software: the instructions that
More informationThe University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003
The University of Melbourne Department of Computer Science and Software Engineering 433-254 Software Design Semester 2, 2003 Answers for Tutorial 7 Week 8 1. What are exceptions and how are they handled
More informationExceptions Handeling
Exceptions Handeling Dr. Ahmed ElShafee Dr. Ahmed ElShafee, Fundamentals of Programming II, ١ Agenda 1. * 2. * 3. * ٢ Dr. Ahmed ElShafee, Fundamentals of Programming II, Introduction During the execution
More informationCrash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++
Crash Course in Java Netprog: Java Intro 1 Why Java? Network Programming in Java is very different than in C/C++ much more language support error handling no pointers! (garbage collection) Threads are
More informationVariables of class Type. Week 8. Variables of class Type, Cont. A simple class:
Week 8 Variables of class Type - Correction! Libraries/Packages String Class, reviewed Screen Input/Output, reviewed File Input/Output Coding Style Guidelines A simple class: Variables of class Type public
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 informationPemrograman Jaringan Network Client
Pemrograman Jaringan Network Client PTIIK - 2012 In This Chapter How to implement an application protocol on the client side. Course Contents 1 Understanding Socket 2 Creating Socket 3 Communicationg With
More informationCS 351 Week Advanced UNIX Programming: Rochkind, Marc J. 1. To learn about System Interprocess Communication (IPC). 2. To learn about Sockets.
CS 351 Week 11 Reading: 1. Advanced UNIX Programming: Rochkind, Marc J. Objectives: 1. To learn about System Interprocess Communication (IPC). 2. To learn about Sockets. Concepts: 1. Interprocess Communication
More informationNetworking and Security
Chapter 03 Networking and Security Mr. Nilesh Vishwasrao Patil Government Polytechnic Ahmednagar Socket Network socket is an endpoint of an interprocess communication flow across a computer network. Sockets
More informationCOMPSCI 230 Threading Week8. Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/]
COMPSCI 230 Threading Week8 Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/] Synchronization Lock DeadLock Why do we need Synchronization in Java? If your code is executing
More informationExample Program. public class ComputeArea {
COMMENTS While most people think of computer programs as a tool for telling computers what to do, programs are actually much more than that. Computer programs are written in human readable language for
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 informationCome & Join Us at VUSTUDENTS.net
Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and
More informationCOMP1406 Tutorial 11
COMP1406 Tutorial 11 Objectives: To gain more practice handling Exceptions. To create your own Exceptions. To practice reading and writing binary files. To practice reading and writing text files. To practice
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 information9. Java Errors and Exceptions
Errors and Exceptions in Java 9. Java Errors and Exceptions Errors and exceptions interrupt the normal execution of the program abruptly and represent an unplanned event. Exceptions are bad, or not? Errors,
More informationLab 5: Java IO 12:00 PM, Feb 21, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Lab 5: Java IO 12:00 PM, Feb 21, 2018 1 The Java IO Library 1 2 Program Arguments 2 3 Readers, Writers, and Buffers 2 3.1 Buffering
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 informationLesson 3: Accepting User Input and Using Different Methods for Output
Lesson 3: Accepting User Input and Using Different Methods for Output Introduction So far, you have had an overview of the basics in Java. This document will discuss how to put some power in your program
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 informationProject #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.
Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple magazine data system. Milestones:
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 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 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 informationClasses Basic Overview
Final Review!!! Classes and Objects Program Statements (Arithmetic Operations) Program Flow String In-depth java.io (Input/Output) java.util (Utilities) Exceptions Classes Basic Overview A class is a container
More information