ICOM 4015-Advanced Programming. Spring Instructor: Dr. Amir H. Chinaei. TAs: Hector Franqui, Jose Garcia, and Antonio Tapia. Reference: Big Java
|
|
- Bertram Oscar Houston
- 5 years ago
- Views:
Transcription
1 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 to Sockets Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez
2 Before the Lab: 1- Read about Sockets in the Java Tutorials 2- Read about Threads in the Java Tutorials 3- Read about String manipulation methods, such as trim(), split() and replace() During the Lab: 1- Login to the computer (1 minute) 2- More about HTTP requests (50 minutes) - In the previous lab, we began our study of HTTP requests. Using them, we were able to enter a chat room and register a user in a chat application. - Today, we are going to continue our study by going deeper into how communication occurs between clients and servers. - We already know that: o In almost every circumstance, clients always begin communication. This communication is normally called a request. o The server is to answer the client s request. The server, under almost every circumstance, must answer to the client. This answer is normally called a response. The server may give two types of responses: A handshake is a response the server gives when the client sends data to it. Normally, the handshake is just an acknowledge to the client to let it know it received data successfully. A data response is a response when the server returns data that the client requested. o There are many ways or mediums for servers and clients to exchange information. This ways or mediums are called protocols. We are studying the HTTP protocol right now. o However, HTTP is just a way to exchange data. The server and the client must agree on what data they exchange. There are many ways to do this. In particular, a commonly used standard is JSON, which you used in the past lab. o What data do servers and client exchanges? On normal operations, it is just a bunch of strings. o These strings contain text that must follow a format in order for the server and client understand what each wants to say (much as humans do). However, we as programmers specify and implement that format and process the text to extract the information we need. o This is what we are going to do today.
3 - Now, we are going to revisit very similar functionality to what we did in last lab. The application has been simplified: there is only one chat room for everyone that enters the app. - We want the server to know (in other words send to the server information) when: o When a new user registers o When we send a message o When we exit the room - We want to know from the server: o A new user (other user) registers o A new message is sent by other user - We are going to implement this functionality by sending Strings to the server whose text values are written in the following format: o registeruser?<username> o sendmessage?<username>;<message> o removeuserrequest?<username> o newuserrequest o newmessagerequest - Note: In the previous format, anything enclosed on < and > brackets denotes a variable. If the username variable is Jose, then the format would be registeruser?jose. - The server is to respond, correspondingly using String with text values in the following format: o userregistered o messagereceived o removalsuccess o <username1;message1,username2;message2,...,usernamen, messagen> OR nonewmessage (if no message has arrived) o <username1,username2,...,usernamen> OR nonewuser (if no user has been registered) - Go to and download the project zip file. It should have the name ICOM4015Lab7-1.zip. Save it in any place you want, as long as you remember the location. - Import the project in Eclipse by clicking File > Import... > General > Existing Project into Workspace > Select archive file and browse to the location where you stored the zip file. - Click Finish.
4 - Once imported, open the class ChatEngine.java. NOTE: Read all steps up to the point where you are supposed to show code to your instructor before proceeding. o Look for the method enterroom(string username). o Read the code and understand the comments. Finish its implementation by completing the code there. Notice the String message is following the format specified above! o Now, basing your work in what you have done in the enterroom() method, finish the implementation the sendmessage(string message) and removeuser() methods. - Show your work to the instructor (20 points) - Now, look at the method hasnewuserarrived(). What should it do? o This method must return true if there s a new user from the server. In other words, if we sent a specific request to the server inquiring if there are new users, we should receive an answer. If this answer is negative, we must return false. o If there s a new user, assign the server s response to the instance variable newuser. Trim the server s response. o Now, finish the implementation of this method basing yourself on the format. - Implement now, in a very similar way, the hasnewmessagearrived() method. o If there are new messages, assign the server s answer to instance variable newmessage. - If everything is correctly implemented, you should run the class ChatRunner.java and see what happens. You should be able to connect to a chat room and chat with other users. - If so, show your work to the instructor (20 points) 3- Introduction to Sockets (70 minutes) - HTTP is a great way to communicate, but is not the only one. - Actually, HTTP works over something called a socket. Your TA should give a brief talk about Sockets and Threads (10 minutes). - In this part of the lab, we are modifying the chat application to work with sockets and not HTTP requests. - Furthermore, we are going to build the server of the chat application. o Notice that in the previous part, the server was already implemented. The reason why you don t see it is because it s not written in Java, but in
5 Javascript. Javascript is nothing like Java, just the name and the syntax looks kind of similar. o The server made in Javascript was based on a technology called Node.js. It s excellent for this kind of applications. o We could also build this server in Java and using HTTP requests, by using something called a Web Socket. However, it s preferred you understand the behavior of sockets in general, as that will help you understand by your own the web socket. - Go to and download the project zip file. It should have the name ICOM4015Lab7-2.zip. Download it to any place you want. - Import the project in Eclipse by File > Import... > General > Existing Project into Workspace > Select archive file. Now browse to the location you downloaded the zip file. - Once imported, go to the ChatEngine.java class. o At the beginning of the file, add to your instance fields the following variables: private Socket clientsocket; private PrintWriter out; private BufferedReader in; o Now, go to the enterroom() method. Initialize the clientsocket instance variable. Initialize using the already existing server and port variables. Initialize the PrintWriter out variable. Use the clientsocket s output stream for initializing the PrintWriter. Initialize the BufferedReader in variable. Use the clientsocket s input stream for initializing the BufferedReader. o Go to the removeuser() method. Close the clientsocket at the end of this method. o Go to the sendrequest() method. o Notice that this method has been changed. We are going to change only this method and leave the rest of the program as it is whenever possible. Send the parameters variable through the socket by printing to the out variable (Hint: much like System.out...). Assign the response of the server to a new String variable. Wait for this new variable to not be null. When it s not null, return it. - Show your work to the instructor (20 points)
6 - Now, we are going to work with the server. Create a new class and name it SocketServer. - Add the following code to your class: public class SocketServer { private static ArrayList<String> registeredusers, sentmessages; private static boolean newuser, newmessage; private static int newusersfetched, newmessagesfetched, sentmessagespos; private static class ServerThread implements Runnable { private Socket socket; public ServerThread(Socket socket) { this.socket = socket; System.out.println("Socket public void run() { public static void main(string[] args) throws IOException { boolean listening = true;
7 newmessage = newuser = false; registeredusers = new ArrayList<String>(); sentmessages = new ArrayList<String>(); newmessagesfetched = newusersfetched = sentmessagespos = 0; ServerSocket serversocket = new ServerSocket(8080); while (listening) { System.out.println("Listening on "); (new Thread(new ServerThread(serverSocket.accept()))).start(); - Let s start by going to the run() method inside the ServerThread inner class. o The run() method will specify what a thread will do when it s executed. o Initialize the following variables using the same code you used in the enterroom() method of the ChatEngine class. Of course, make sure socket s variable name agrees... PrintWriter out =... BufferedReader in =... o Note: Declaring these will make Eclipse complain and ask you for a try block. Keep the rest of the code inside the try block. o Declare a new String, input. o Now we must check what the value of input is. Remember the format? The client will send us some strings in a specific format. We now must interpret that format and answer the client correspondingly. o Copy the following code after you declare the input variable: do { if (input.contains("registeruser")) { String[] splitresult = input.split(... )
8 String username =... registeredusers.add(...); output = "..."; newuser = true; out.println(output); // Rest of code here... while ((input = in.readline())!= null); socket.close(); o Inside the if statement: Basing yourself on the format, process the string input. You want the username part of that String. You must use the split() method to obtain the username part. HINT: What divides the username from the other string, registeruser? Replace the... with that divider. You must precede the divider by two backslashes. If the divider is x, your method should look like input.split( \\x ); The username is now on the second element of the array Add the user to the registeredusers ArrayList. Replace the... with the name of the corresponding variable. Answer the client by telling it that the user was registered (Hint: remember the format...). Replace the... with the text in the appropriate format. o Add an else if statement and check if input contains information for sending a message (Hint: what is the format for the client to send a message?) In a very similar way to the previous method, implement the server action for when a client sends a message.
9 Remember to split the incoming input String. You may need to do two splits. o Add another else if statement and check if the input contains information for removing a user. In a very similar way to the previous two, implement this method. Notice some points: Now we must remove a user, not add it. Removing a user means the client is closing. Close the socket too. Even if there s no new user added, the variable newuser must be set to true (why?) - Show your work to the instructor (20 points) - The next step is to implement the functionality to let the client know if new messages or new users have arrived. - Copy the following code after your last else if statement: else if (input.contains("newuserrequest")) { if (newuser == true) { if (newusersfetched < registeredusers.size()) { else { // Your code to prepare the response and send here newuser = false; newusersfetched = 0; // Your code for notifying no new users here else { // Your code for notifying no new users here else if (input.contains("newmessagerequest")) {
10 if (newmessage == true) { if (newmessagesfetched < registeredusers.size()) { // Your code to prepare the response and send here else { newmessage = false; newmessagesfetched = 0; sentmessagespos = sentmessages.size(); // Your code for notifying no new messages here else { // Your code for notifying no new messages here - For the new user request action, do the following: o Increment the amount of newusersfetched variable. o Declare a new String variable, result. o Iterate over the whole registeredusers ArrayList and add to the result variable each element of registeredusers followed by a comma,. o Write the result into the socket. o In the other else statements, write to the socket the value that indicates the client there s no new users (Hint: the format...) - In a very similar way, implement the new message request action. o Notice the following points: Instead of iterating from zero, you should start at the variable sentmessagepos. Instead of adding a, following each message, you should add the following: %MessageSeparator% - Show your work to the instructor (20 points).
11 - Now, run your server first by right clicking the SocketServer.java class in the Package Explorer and selecting Run As > Java Application. - Right click the ChatRunner.java class and run it by selecting Run As > Java Application. - Test your chat client. It should work for just one user. If it does, then try opening another chat client by right-clicking the ChatRunner.java class and selecting Run As > Java Application. - If everything works, you should see exactly the same behavior as with the HTTP chat server. - Show you work to the instructor (20 points) After the Lab: 1- Investigate a little bit about inner classes 2- Think on how today s lab can help you to develop Project 2
12 Evaluating Lab 6 Write Your Section# here:.. Please evaluate the quality of the lab and performance of the instructors by filling up the following table and give it to your lab representative. (Choose 5 as the highest and 1 as the lowest grade). The lab started on time SHARP. Items The instructor was able to help you during the HTTP part and answer questions. The instructor gave an understandable presentation of Socket and Threads and followed timeline. The instructor was able to help you during the implementation of the server in the Sockets part. The instructor overall followed the specified timeline for each step You found the lab today overall Great (helpful, fruitful, interesting, etc.). Evaluating Lab 6 Write Your Section# here:.. Please evaluate the quality of the lab and performance of the instructors by filling up the following table and give it to your lab representative. (Choose 5 as the highest and 1 as the lowest grade). The lab started on time SHARP. Items The instructor was able to help you during the HTTP part and answer questions. The instructor gave an understandable presentation of Socket and Threads and followed timeline. The instructor was able to help you during the implementation of the server in the Sockets part. The instructor overall followed the specified timeline for each step You found the lab today overall Great (helpful, fruitful, interesting, etc.).
13
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 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 informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Spring 2017 Reading: Chapter 2, Relevant Links - Threads Some Material in these slides from J.F Kurose and K.W. Ross All material
More informationLab 10: Sockets 12:00 PM, Apr 4, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lab 10: Sockets 12:00 PM, Apr 4, 2018 Contents 1 The Client-Server Model 1 1.1 Constructing Java Sockets.................................
More informationProject 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.
Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple movie data system. Milestones: 1. Use
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 informationCSCD 330 Network Programming
CSCD 330 Network Programming Lecture 8 Client-Server Programming Threads Spring 2018 Reading: Chapter 2, Relevant Links - Threads Some Material in these slides from J.F Kurose and K.W. Ross All material
More 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 informationprotocols September 15,
Contents SCI 351 4 Protocols, WWW Internet applications WWW, document technology Lennart Herlaar Original slides by Piet van Oostrum September 15, 2003 SCI351-4 1 X SCI351-4 1 X Internet applications How
More 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 informationCS 351 Design of Large Programs Sockets Example
CS 351 Design of Large Programs Sockets Example Brooke Chenoweth University of New Mexico Spring 2019 Socket Socket(String host, int port) InputStream getinputstream() OutputStream getoutputstream() void
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationAnnouncements. 1. Forms to return today after class:
Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.
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 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 informationCS 10: Problem solving via Object Oriented Programming. Client/Server
CS 10: Problem solving via Object Oriented Programming Client/Server Agenda 1. Sockets 2. Server 3. MulAthreaded server 4. Chat server 2 Sockets are a way for computers to communicate IP: 1.2.3.4 HTTP
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 informationProject 2 - A Simple Chat Program
Project 2 - A Simple Chat Program Minimum Effort Due: (Part 1) 2/11/2007 (Sunday) Complete Project Due: (Part 2) 2/23/2007 (Friday) Late Project Due: (Last Chance) 2/24/2007 (Saturday) Overview In this
More informationLecture 17. For Array Class Shenanigans
Lecture 17 For Array Class Shenanigans For or While? class WhileDemo { public static void main(string[] args){ int count = 1; while (count < 11) { System.out.println("Count is: " + count); count++; Note:
More informationFiles & Exception Handling. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
Files & Exception Handling CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Exception Handling (try catch) Suppose that a line of code may make your
More informationWeb Server Project. Tom Kelliher, CS points, due May 4, 2011
Web Server Project Tom Kelliher, CS 325 100 points, due May 4, 2011 Introduction (From Kurose & Ross, 4th ed.) In this project you will develop a Web server in two steps. In the end, you will have built
More informationThread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections
Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent
More informationObject Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang
Object Oriented Programming and Design in Java Session 2 Instructor: Bert Huang Announcements TA: Yipeng Huang, yh2315, Mon 4-6 OH on MICE clarification Next Monday's class canceled for Distinguished Lecture:
More informationCS2110: Software Development Methods. Maps and Sets in Java
CS2110: Software Development Methods Maps and Sets in Java These slides are to help with the lab, Finding Your Way with Maps Today s lab uses Maps (and Sets but just a little). Readings from textbook:
More informationCMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists
CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists Due on Tuesday February 24, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI
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 informationAdvanced Object-oriented Programming
COMP 213 Advanced Object-oriented Programming Lecture 21 Concurrency What is Concurrency? Concurrency is when two or more programs execute at the same time, either: sharing the same processor (multi-threading),
More informationAnswer Key. 1. General Understanding (10 points) think before you decide.
Answer Key 1. General Understanding (10 points) Answer the following questions with yes or no. think before you decide. Read the questions carefully and (a) (2 points) Does the interface java.util.sortedset
More informationM257 Past Paper Oct 2007 Attempted Solution
M257 Past Paper Oct 2007 Attempted Solution Part 1 Question 1 The compilation process translates the source code of a Java program into bytecode, which is an intermediate language. The Java interpreter
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More information13 th Windsor Regional Secondary School Computer Programming Competition
SCHOOL OF COMPUTER SCIENCE 13 th Windsor Regional Secondary School Computer Programming Competition Hosted by The School of Computer Science, University of Windsor WORKSHOP I [ Overview of the Java/Eclipse
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 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 informationComputing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer
Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company
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 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 informationCSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7. Question 1. (2 points) What is the difference between a stream and a file?
CSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7 Question 1. (2 points) What is the difference between a stream and a file? A stream is an abstraction representing the flow of data from one place to
More informationQuestion 1. (2 points) What is the difference between a stream and a file?
CSE 143 Sp03 Midterm 2 Page 1 of 7 Question 1. (2 points) What is the difference between a stream and a file? Question 2. (2 points) Suppose we are writing an online dictionary application. Given a word
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 informationDistributed Systems Recitation 2. Tamim Jabban
15-440 Distributed Systems Recitation 2 Tamim Jabban Agenda Communication via Sockets in Java (this enables you to complete PS1 and start P1 (goes out today!)) Multi-threading in Java Coding a full Client-Server
More 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 informationCMPSCI 187 / Spring 2015 Postfix Expression Evaluator
CMPSCI 187 / Spring 2015 Postfix Expression Evaluator Due on Thursday, 05 March, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI 187 / Spring 2015
More informationLecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan
Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful
More informationA PROGRAM IS A SEQUENCE of instructions that a computer can execute to
A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form
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 informationLast Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Writing a Simple Java Program Intro to Variables Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch
More informationProgramming Methods Dr Robert Harle
Programming Methods Dr Robert Harle IA NST CS and CST Lent 2008/09 Handout 4 Our Motivating Example We re going to make the world s simplest web server It s not going to challenge apache etc But it will
More informationASSIGNMENT 5 Objects, Files, and a Music Player
ASSIGNMENT 5 Objects, Files, and a Music Player COMP-202A, Fall 2009, All Sections Due: Thursday, December 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you
More informationCondition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.
Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes
More informationChapter 2. Network Chat
Chapter 2. Network Chat In a multi-player game, different players interact with each other. One way of implementing this is to have a centralized server that interacts with each client using a separate
More informationICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit
ICOM 4015 Advanced Programming Laboratory Chapter 1 Introduction to Eclipse, Java and JUnit University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís 1 Introduction This
More informationCS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03
CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03 Topics: Threading, Synchronization 1 Threading Suppose we want to create an automated program that hacks into a server. Many encryption
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 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 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 informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationFinal Exam. Programming Assignment 3. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Interfaces vs. Inheritance Abstract Classes Inner Classes Readings This Week: No new readings. Consolidate! (Reminder: Readings
More information1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 19, 2004
1.00 Introduction to Computers and Engineering Problem Solving Final Examination - May 19, 2004 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions, you do not
More informationASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists
ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists COMP-202B, Winter 2009, All Sections Due: Tuesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise
More informationJava Review Outline. basics exceptions variables arrays modulo operator if statements, booleans, comparisons loops: while and for
Java Review Outline basics exceptions variables arrays modulo operator if statements, booleans, comparisons loops: while and for Java basics write a simple program, e.g. hello world http://www2.hawaii.edu/~esb/2017fall.ics211/helloworl
More informationGeneral Use. Searching for Assets (All users) Browsing for Assets (All users) Viewing and Downloading an Asset (All Users)
User Guide Rev1.1 Table of Contents General Use... 2 Searching for Assets (All users)... 2 Browsing for Assets (All users)... 2 Viewing and Downloading an Asset (All Users)... 2 Downloading Large Files
More informationCS 231 Data Structures and Algorithms Fall 2018
CS 231 Data Structures and Algorithms Fall 2018 Interface, Node Based Stack, Exception Handling, Class BufferedReader Lecture 12 October 1, 2018 Prof. Zadia Codabux 1 Agenda Node based implementation of
More informationDistributed Systems Project 4 Assigned: Friday March 20 Due: Friday April 3, 11:59pm
95-702 Distributed Systems Project 4 Assigned: Friday March 20 Due: Friday April 3, 11:59pm Project Topics: Java RMI and a distributed, Mobile to Cloud application This project has 2 tasks. Task 1 is a
More informationSTUDENT LESSON A12 Iterations
STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of
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 informationASSIGNMENT 5 Objects, Files, and More Garage Management
ASSIGNMENT 5 Objects, Files, and More Garage Management COMP-202B, Winter 2010, All Sections Due: Wednesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified,
More informationCSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen
CSCI 136 Data Structures & Advanced Programming Fall 2018 Instructors Bill Lenhart & Bill Jannen Administrative Details Lab 1 handout is online Prelab (should be completed before lab): Lab 1 design doc
More informationM257 Past Paper Oct 2008 Attempted Solution
M257 Past Paper Oct 2008 Attempted Solution Part 1 Question 1 A version of Java is a particular release of the language, which may be succeeded by subsequent updated versions at a later time. Some examples
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 80 points Due Date: Friday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Monday, February 5, 11:59 pm General information This assignment is to be done
More informationQuestion 0. (1 point) Write the correct ID of the section you normally attend on the cover page of this exam if you have not already done so.
CSE 143 Sp04 Midterm 2 Page 1 of 10 Reference information about some standard Java library classes appears on the last pages of the test. You can tear off these pages for easier reference during the exam
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 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 informationChapter 3: A Larger Example: SocketChat
page 1 Chapter 3: A Larger Example: SocketChat In this chapter we are going to look at three versions of a larger socket-based example: a simple `chat' application. The application does not have many capabilities,
More informationSteps for Implementing a Server
Agenda 5 Steps for creating a server 1. Create a ServerSocket object 2. Create a Socket object from ServerSocket 3. Create an input stream 4. Create an output stream 5. Do I/O with input and output streams
More informationMath Modeling in Java: An S-I Compartment Model
1 Math Modeling in Java: An S-I Compartment Model Basic Concepts What is a compartment model? A compartment model is one in which a population is modeled by treating its members as if they are separated
More informationFiles. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
Files CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Files and Text Files A file is a collection of data, that is saved on a hard drive. A text
More informationFiles. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington
Files CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Files and Text Files A file is a collection of data, that is saved on a hard drive. A text
More informationControls Structure for Repetition
Controls Structure for Repetition So far we have looked at the if statement, a control structure that allows us to execute different pieces of code based on certain conditions. However, the true power
More informationRules and syntax for inheritance. The boring stuff
Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for
More informationJava Programming Fundamentals - Day Instructor: Jason Yoon Website:
Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused
More informationNetwork Programming: Servers
2012 Marty Hall Network Programming: Servers Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/java.html 3 Customized Java EE Training: http://courses.coreservlets.com/
More informationCmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #13, Concurrency, Interference, and Synchronization John Ridgway March 12, 2015 Concurrency and Threads Computers are capable of doing more
More informationAPCS Semester #1 Final Exam Practice Problems
Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester
More informationLecture 9: Lists. MIT-AITI Kenya 2005
Lecture 9: Lists MIT-AITI Kenya 2005 1 In this lecture we will learn. ArrayList These are re-sizeable arrays LinkedList brief overview Differences between Arrays and ArrayLists Casting Iterator method
More informationCSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7
CSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7 Reference information about some standard Java library classes appears on the last pages of the test. You can tear off these pages for easier reference
More informationASSIGNMENT 4. COMP-202, Fall 2013, All Sections. Due: December 6 th,2013(23:59)
ASSIGNMENT 4 COMP-202, Fall 2013, All Sections Due: December 6 th,2013(23:59) Please read the entire PDF before starting. You must do this assignment individually and, unless otherwise specified, you must
More information5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.
Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you
More informationSee What Your Robot Sees
See What Your Robot Sees Matthew Li, Ashvin Nair Winchester High School matthew.yj.li@gmail.com, nair.ashvin@gmail.com Introduction See What Your Robot Sees One of the major pitfalls of embedded systems
More informationImplement an ADT while using Subversion
1 Objectives Learn to use Subversion Implement an ADT while using Subversion In this lab, you learn about the version control tool called Subversion and you will implement a Java class given an interface.
More informationJava How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data
More informationTCP and Concurrency. The third assignment at DA
TCP and Concurrency The third assignment at DA2402 2009-03-05 Jonas Lundberg/Ola Flygt adapted to Java by Marcus Edvinsson maintained by Marcus Edvinsson Matematiska och systemtekniska institutionen, MSI
More informationRepetition Structures
Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements
More informationG51PGP Programming Paradigms. Lecture OO-4 Aggregation
G51PGP Programming Paradigms Lecture OO-4 Aggregation 1 The story so far We saw that C code can be converted into Java code Note real object oriented code though Hopefully shows you how much you already
More informationAdministration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11
Administration Exceptions CS 99 Summer 2000 Michael Clarkson Lecture 11 Lab 10 due tomorrow No lab tomorrow Work on final projects Remaining office hours Rick: today 2-3 Michael: Thursday 10-noon, Monday
More informationLanguage Reference Manual
ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents
More informationCSE 142 Sp02 Final Exam Version A Page 1 of 14
CSE 142 Sp02 Final Exam Version A Page 1 of 14 Basic reference information about collection classes that you may find useful when answering some of the questions. Methods common to all collection classes
More informationAPPM 2460 Matlab Basics
APPM 2460 Matlab Basics 1 Introduction In this lab we ll get acquainted with the basics of Matlab. This will be review if you ve done any sort of programming before; the goal here is to get everyone on
More informationPrinciples of Computer Science I
Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120A - Fall 2004 Lecture Unit 7 Review Chapter 4 Boolean data type and operators (&&,,) Selection control flow structure if, if-else, nested
More information