Size: px
Start display at page:

Download ""

Transcription

1

2

3

4

5

6 import java.net.socket; import java.net.serversocket; import java.io.ioexception; /* Java Server */ public class Nets static Socket thesocket; static ServerThread client[] = new ServerThread[10]; static ServerSocket theserversocket; static Data rundata = new Data(); public static void main(string args[]) throws IOException int i; System.out.println("Server coming up..."); theserversocket = new ServerSocket(1234); rundata.start(); /* Data */ while (true) thesocket = theserversocket.accept(); /* Client connect */ for (i=0;i<10;i++) if ((client[i] == null) (!client[i].isalive())) break; /* */ if (i<10) client[i] = new ServerThread(theSocket); /* */ client[i].start(); System.out.println("Connect client " + i);

7 else System.out.println("Rejected a connection..."); import java.net.socket; import java.io.*; import java.awt.*; /* Server port program */ public class ServerThread extends Thread public static double All[] = new double[12]; Socket mysocket; DataInputStream datain; DataOutputStream dataout; public ServerThread(Socket s) throws IOException mysocket = s; datain = new DataInputStream(new BufferedInputStream(mySocket.getInputStream())); dataout = new DataOutputStream(new BufferedOutputStream(mySocket.getOutputStream())); public void run() System.out.println("Client come from " + datain.readline()); while (talk()) /* Client */ yield(); mysocket.close(); catch (IOException E) ; System.out.println("Client game over!"); synchronized private boolean talk() throws IOException int i; char x; x = datain.readchar(); System.out.println("Accept: " + x); if(x == 'Q') return false; /* Client */ if(x == 'A') /* Client */ for (i=0;i<12;++i)

8 dataout.writedouble(all[i]); /* Client */ System.out.print(" Out: " + All[i]); System.out.println(""); dataout.flush(); return true; import java.io.*; import java.awt.*; /* */ * */ /*,... */ public class Data extends Thread public static double All[] = new double[12]; public Data() int i; for(i=0;i<12;i++) All[i] = 0.0; public void run() int i, counter = 0; while(true) counter ++; ServerThread.All[0] = (double)counter; for(i=1; i<12; i++) ServerThread.All[i] = java.lang.math.random() * 10.; /* */ Thread.sleep(1000); catch(interruptedexception e) import java.awt.*; import java.io.*;

9 import java.net.*; import java.applet.applet; /* * class for the "Client" Applet */ public class client extends Applet implements Runnable TextField addrfield; TextField statusfield; Button openbutton; Button closebutton; Button nextbutton; Panel p1, p2; TextField datafield[] = new TextField[12];; double now_data[] = new double[12]; Socket socket; DataInputStream in; DataOutputStream out; Thread thread; String hostname = new String(); public void init () int i; this.setlayout(new BorderLayout()); addrfield = new TextField(" ", 20); statusfield = new TextField("Data", 40); for(i=0;i<12;i++) datafield[i] = new TextField("0.0", 10); resize (500, 500); p1 = new Panel (); p1.setlayout (new FlowLayout ()); p2 = new Panel (); p2.setlayout (new FlowLayout ()); add ("North", p1); add ("Center", p2); p1.add (new Label ("Address")); p1.add (addrfield); p1.add (openbutton = new Button ("Open")); p1.add (closebutton = new Button ("Close")); p1.add (nextbutton = new Button ("Next")); p2.add (new Label ("Data List:")); p2.add (statusfield); for(i=0;i<12;i++) p2.add(datafield[i]); thread = new Thread (this); public boolean action (Event evt, Object arg) if (evt.target == openbutton evt.target == addrfield)

10 thread.stop (); thread = new Thread (this); thread.start (); else if (evt.target == nextbutton) out.writechar('a'); out.flush(); catch (IOException e) statusfield.settext("write Error..."); else if (evt.target == closebutton) out.writechar('q'); out.flush(); catch (IOException e) statusfield.settext("write Error..."); thread.stop (); return true; public void destroy() out.writechar('q'); out.flush(); catch (IOException e) statusfield.settext("write Error..."); socket.close(); catch (IOException e) thread.stop(); public void run () int i; socket = new Socket (addrfield.gettext (), 1234); catch (UnknownHostException e) statusfield.settext("unknown host\n"); return; catch (IOException e2)

11 statusfield.settext("unable to open socket\n"); return; in = new DataInputStream(new BufferedInputStream(socket.getInputStream())); out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); catch (IOException e) statusfield.settext("unable to open streams\n"); return; statusfield.settext("connect..."); hostname = InetAddress.getLocalHost().toString() + "\n"; catch (UnknownHostException e) hostname = "Unknown address\n"; out.writechars(hostname); out.flush(); catch (IOException e) statusfield.settext("write data Error!"); thread.stop (); while (true) out.writechar('a'); out.flush(); catch (IOException e) statusfield.settext("write data Error!"); thread.stop (); for(i=0;i<12;i++) now_data[i] = in.readdouble(); catch (IOException e) statusfield.settext("read data Error!"); thread.stop ();

12 statusfield.settext("new Data"); for(i=0;i<12;i++) datafield[i].settext(string.valueof(now_data[i])); Thread.sleep(2000); catch(interruptedexception e) <html> <head> <title> Monitor Page </title> </head> <applet code="client.class" width=400 height=400> </applet> <hr size=4> </html>

WINDOWS SOCKET PROGRAMMING

WINDOWS SOCKET PROGRAMMING WINDOWS SOCKET PROGRAMMING Headers and libraries All the declarations are in one header, winsock.h Your socket programs must link to the Winsock library (usually called wsock32.lib or winsock32.lib) Initialization

More information

package p1; public class Derivation extends Protection { public Derivation() { System.out.println("Derived class constructor");

package p1; public class Derivation extends Protection { public Derivation() { System.out.println(Derived class constructor); PROGRAM:1 WAP to implement the packages //package 1: package p1; public class Protection int n=1; public int n_pub=2; private int n_pri=3; protected int n_pro=4; public Protection () System.out.println("Base

More information

A socket is a software endpoint that establishes bidirectional communication between a server program and one or more client programs.

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

Object-Oriented Programming in Java

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

JAVA - NETWORKING (SOCKET PROGRAMMING)

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

Principles, Models, and Applications for Distributed Systems M

Principles, Models, and Applications for Distributed Systems M Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Exercitation 3 Connected Java Sockets Jacopo De Benedetto Distributed architecture

More information

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

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network

More information

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server. CSE 660 Lab 7 Submitted by: Arumugam Thendramil Pavai 1)Simple Remote Calculator Server is created using ServerSocket class of java Server.java import java.io.ioexception; import java.net.serversocket;

More information

Principles, Models, and Applications for Distributed Systems M

Principles, Models, and Applications for Distributed Systems M Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M Lab assignment 4 (worked-out) Connection-oriented Java Sockets Luca Foschini Winter

More information

Java Networking (sockets)

Java Networking (sockets) Java Networking (sockets) Rui Moreira Links: http://java.sun.com/docs/books/tutorial/networking/toc.html#sockets http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets_p.html Networking Computers

More information

CS 3331 Advanced Object-Oriented Programming Final Exam

CS 3331 Advanced Object-Oriented Programming Final Exam Fall 2015 (Thursday, December 3) Name: CS 3331 Advanced Object-Oriented Programming Final Exam This test has 5 questions and pages numbered 1 through 10. Reminders This test is closed-notes and closed-book.

More information

Step 1: One time server

Step 1: One time server I seguenti codici saranno utili all instaurazione di una chat tra server e client, saranno presenti vari step, ognuno dei quali avrà delle caratteristiche differenti. Step 1: One time server Il programma

More information

Module 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet

Module 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet About Applets Module 5 Applets An applet is a little application. Prior to the World Wide Web, the built-in writing and drawing programs that came with Windows were sometimes called "applets." On the Web,

More information

CS 351 Week Advanced UNIX Programming: Rochkind, Marc J. 1. To learn about System Interprocess Communication (IPC). 2. To learn about Sockets.

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

agentmom User's Manual

agentmom User's Manual July 2000 agentmom User's Manual Scott A. DeLoach GRADUATE SCHOOL OF ENGINEERING AND MANAGEMENT AIR FORCE INSTITUTE OF TECHNOLOGY WRIGHT-PATTERSON AIR FORCE BASE, OHIO Approved for public release; distribution

More information

Chapter 3: A Larger Example: SocketChat

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

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)

More information

URL Kullanımı Get URL

URL Kullanımı Get URL Networking 1 URL Kullanımı Get URL URL info 2 import java.io.*; import java.net.*; public class GetURL { public static void main(string[] args) { InputStream in = null; OutputStream out = null; // Check

More information

Java Basics 5 - Sockets. Manuel Oriol - May 4th, 2006

Java Basics 5 - Sockets. Manuel Oriol - May 4th, 2006 Java Basics 5 - Sockets Manuel Oriol - May 4th, 2006 Connected / Disconnected Modes Connected mode: path chosen and packets arrive all, in correct order (e.g. Phone) Disconnected mode: path not chosen

More information

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

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary CPSC 441 Tutorial TCP Server Department of Computer Science University of Calgary TCP Socket Client Server Connection Request Server Listening on welcoming socket Client Socket Server Socket Data Simple

More information

Homework 3 Huffman Coding. Due Thursday October 11

Homework 3 Huffman Coding. Due Thursday October 11 Homework 3 Huffman Coding Due Thursday October 11 Huffman Coding Implement Huffman Encoding and Decoding and the classes shown on the following slides. You will also need to use Java s stack class HuffmanEncode

More information

Threads in Java (Deitel & Deitel)

Threads in Java (Deitel & Deitel) Threads in Java (Deitel & Deitel) OOutline 1 Introduction 1 Class Thread: An Overview of the Thread Methods 1 Thread States: Life Cycle of a Thread 1 Thread Priorities and Thread Scheduling 1 Thread Synchronization

More information

Java Programs. System.out.println("Dollar to rupee converion,enter dollar:");

Java Programs. System.out.println(Dollar to rupee converion,enter dollar:); Java Programs 1.)Write a program to convert rupees to dollar. 60 rupees=1 dollar. class Demo public static void main(string[] args) System.out.println("Dollar to rupee converion,enter dollar:"); int rs

More information

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

Reading from URL. Intent - open URL  get an input stream on the connection, and read from the input stream. Simple Networking Loading applets from the network. Applets are referenced in a HTML file. Java programs can use URLs to connect to and retrieve information over the network. Uniform Resource Locator (URL)

More information

Java networking using sockets

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

More information

THIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM

THIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM UNIVERSITY OF LONDON GOLDSMITHS COLLEGE B. Sc. Examination 2012 COMPUTER SCIENCE IS52025A Internet and Distributed Programming Duration: 2 hours 15 minutes Date and time: There are five questions in this

More information

CSCD 330 Network Programming Spring 2018

CSCD 330 Network Programming Spring 2018 CSCD 330 Network Programming Spring 2018 Lecture 6 Application Layer Socket Programming in Java Reading for Java Client/Server see Relevant Links Some Material in these slides from J.F Kurose and K.W.

More information

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O

Week 12. Streams and File I/O. Overview of Streams and File I/O Text File I/O Week 12 Streams and File I/O Overview of Streams and File I/O Text File I/O 1 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file

More information

John Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer

John Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer John Cowell Essential Java Fast How to write object oriented software for the Internet with 64 figures Jp Springer Contents 1 WHY USE JAVA? 1 Introduction 1 What is Java? 2 Is this book for you? 2 What

More information

MYcsvtu Notes. Experiment-1. AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions

MYcsvtu Notes. Experiment-1. AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions Experiment-1 AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions String Xor(String s1,string s2) char s1array[]=s1.tochararray(); char s2array[]=s2.tochararray();

More information

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng. CS 355 Computer Networking Wei Lu, Ph.D., P.Eng. Chapter 2: Application Layer Overview: Principles of network applications? Introduction to Wireshark Web and HTTP FTP Electronic Mail: SMTP, POP3, IMAP

More information

Networking Code CSCI 201 Principles of Software Development

Networking Code CSCI 201 Principles of Software Development Networking Code CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Server Networking Client Networking Program Outline USC CSCI 201L Server Software A server application

More information

Topic 10: Network Programming

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

2018/2/5 话费券企业客户接入文档 语雀

2018/2/5 话费券企业客户接入文档 语雀 1 2 2 1 2 1 1 138999999999 2 1 2 https:lark.alipay.com/kaidi.hwf/hsz6gg/ppesyh#2.4-%e4%bc%81%e4%b8%9a%e5%ae%a2%e6%88%b7%e6%8e%a5%e6%94%b6%e5%85%85%e5 1/8 2 1 3 static IAcsClient client = null; public static

More information

Java for Interfaces and Networks

Java for Interfaces and Networks Java for Interfaces and Networks Threads and Networking Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces and Networks Lecture

More information

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

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket Objectives TCP connections To understand programming of clients that connect to servers via TCP To understand the basics of programming of servers that accept TCP connections To practice programming of

More information

Multiplayer Game Programming 2/26

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

OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70

OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70 I,.. CI/. T.cH/C8E/ODD SEM/SEM-5/CS-504D/2016-17... AiIIIII "-AmI u...iir e~ IlAULAKA ABUL KALAM AZAD UNIVERSITY TECHNOLOGY,~TBENGAL Paper Code: CS-504D OF OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3

More information

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

public static void main(string[] args) throws IOException { sock = new Socket(args[0], Integer.parseInt(args[1])); Echo Client&Server Application EchoClient import java.net.*; import java.io.*; class EchoClient public static void main(string[] args) throws IOException if (args.length < 2) number>"); System.err.println("Usage:

More information

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

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

Multithread Computing

Multithread Computing Multithread Computing About This Lecture Purpose To learn multithread programming in Java What You Will Learn ¾ Benefits of multithreading ¾ Class Thread and interface Runnable ¾ Thread methods and thread

More information

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

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

Performing input and output operations using a Byte Stream

Performing input and output operations using a Byte Stream Performing input and output operations using a Byte Stream public interface DataInput The DataInput interface provides for reading bytes from a binary stream and reconstructing from them data in any of

More information

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

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark Network Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Outline Socket programming If we have the time: Remote method invocation (RMI) 2 Socket Programming Sockets

More information

Today. Robotics and Autonomous Systems. Jason and LeJOS. Jason and LeJOS. Lecture 23: LeJOS and Jason. Richard Williams

Today. Robotics and Autonomous Systems. Jason and LeJOS. Jason and LeJOS. Lecture 23: LeJOS and Jason. Richard Williams Today Robotics and Autonomous Systems Lecture 23: LeJOS and Jason Richard Williams Department of Computer Science University of Liverpool Today we will just go through an example of how to interface Jason

More information

Robotics and Autonomous Systems

Robotics and Autonomous Systems 1 / 59 Robotics and Autonomous Systems Lecture 23: LeJOS and Jason Simon Parsons Department of Computer Science University of Liverpool 2 / 59 Today Today we will just go through an example of how to interface

More information

Robotics and Autonomous Systems

Robotics and Autonomous Systems Robotics and Autonomous Systems Lecture 23: LeJOS and Jason Simon Parsons Department of Computer Science University of Liverpool 1 / 59 Today Today we will just go through an example of how to interface

More information

CORBA Java. Java. Java. . Java CORBA. Java CORBA (RMI) CORBA ORB. . CORBA. CORBA Java

CORBA Java. Java. Java. . Java CORBA. Java CORBA (RMI) CORBA ORB. . CORBA. CORBA Java CORBA Java?? OMG CORBA IDL C, C++, SmallTalk, Ada Java COBOL, ORB C Ada Java C++ CORBA Java CORBA Java (RMI) JDK12 Java CORBA ORB CORBA,, CORBA? CORBA,,, CORBA, CORBA CORBA Java (, ) Java CORBA Java :

More information

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An

More information

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

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

Internet Technology 2/7/2013

Internet Technology 2/7/2013 Sample Client-Server Program Internet Technology 02r. Programming with Sockets Paul Krzyzanowski Rutgers University Spring 2013 To illustrate programming with TCP/IP sockets, we ll write a small client-server

More information

Contents. 6-1 Copyright (c) N. Afshartous

Contents. 6-1 Copyright (c) N. Afshartous Contents 1. Classes and Objects 2. Inheritance 3. Interfaces 4. Exceptions and Error Handling 5. Intro to Concurrency 6. Concurrency in Java 7. Graphics and Animation 8. Applets 6-1 Copyright (c) 1999-2004

More information

What is a Thread? Individual and separate unit of execution that is part of a process. multiple threads can work together to accomplish a common goal

What is a Thread? Individual and separate unit of execution that is part of a process. multiple threads can work together to accomplish a common goal Java Threads What is a Thread? Individual and separate unit of execution that is part of a process multiple threads can work together to accomplish a common goal Video Game example one thread for graphics

More information

Java for Interfaces and Networks (DT3029)

Java for Interfaces and Networks (DT3029) Java for Interfaces and Networks (DT3029) Lecture 3 Threads and Networking Federico Pecora federico.pecora@oru.se Center for Applied Autonomous Sensor Systems (AASS) Örebro University, Sweden Capiscum

More information

OOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like:

OOP Assignment V. For example, the scrolling text (moving banner) problem without a thread looks like: OOP Assignment V If we don t use multithreading, or a timer, and update the contents of the applet continuously by calling the repaint() method, the processor has to update frames at a blinding rate. Too

More information

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis

Multi-threaded Web Server (Assignment 1) Georgios Georgiadis Multi-threaded Web Server (Assignment 1) Georgios Georgiadis Overview Multi-threaded Web Server What to do and how to do it HTTP messages Processes and threads ComputerComm '09 2 Multi-threaded Web Server

More information

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

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

More information

Applet. 1. init (): called once by the applet containers when an applet is loaded for execution.

Applet. 1. init (): called once by the applet containers when an applet is loaded for execution. )*(applet classes from class JApplet. Applet Applet : are Java programs that are typically embedded in HTML (Extensible Hyper- Text Markup Language) documents. 2.Life cycle method : 1-init () 2-start ()

More information

Assignment -3 Source Code. Student.java

Assignment -3 Source Code. Student.java import java.io.serializable; Assignment -3 Source Code Student.java public class Student implements Serializable{ public int rollno; public String name; public double marks; public Student(int rollno,

More information

Socket Programming(TCP & UDP) Sanjay Chakraborty

Socket Programming(TCP & UDP) Sanjay Chakraborty Socket Programming(TCP & UDP) Sanjay Chakraborty Computer network programming involves writing computer programs that enable processes to communicate with each other across a computer network. The endpoint

More information

Distributed Objects. Remote Method Invokation

Distributed Objects. Remote Method Invokation Distributed Objects Remote Method Invokation Distributed Systems Object Oriented Paradigm invoke method Object 1 Object 2 respond Distributed Object Oriented Paradigm Client Host/Process invoke method

More information

CSCI 201L Written Exam #1 Fall % of course grade

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

CS 351 Design of Large Programs Sockets Example

CS 351 Design of Large Programs Sockets Example CS 351 Design of Large Programs Sockets Example Brooke Chenoweth University of New Mexico Spring 2019 Socket Socket(String host, int port) InputStream getinputstream() OutputStream getoutputstream() void

More information

Process management. Desarrollo de Aplicaciones en Red. Process in memory. Concepts. Process state diagram. Process state

Process management. Desarrollo de Aplicaciones en Red. Process in memory. Concepts. Process state diagram. Process state Process management Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano A process can be thought as a program in execution. Process are the unit of work on modern time-sharing

More information

LEJOS AND JASON ROBOTICS AND AUTONOMOUS SYSTEMS. Today. Today we will just go through an example of how to interface. Department of Computer Science

LEJOS AND JASON ROBOTICS AND AUTONOMOUS SYSTEMS. Today. Today we will just go through an example of how to interface. Department of Computer Science ROBOTICS AND AUTONOMOUS SYSTEMS Simon Parsons Department of Computer Science University of Liverpool LECTURE 24 comp329-2013-parsons-lect24 2/58 Today Today we will just go through an example of how to

More information

Title Description Participants Textbook

Title Description Participants Textbook Podcast Ch23c Title: Binary Files Description: Overview of binary files; DataInputStream; DataOutputStream; Program 23.1; file compression Participants: Barry Kurtz (instructor); John Helfert and Tobie

More information

Chapter 2. Network Chat

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

Question 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below.

Question 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below. Name: 1.124 Quiz 2 Thursday November 9, 2000 Time: 1 hour 20 minutes Answer all questions. All questions carry equal marks. Question 1. Show the steps that are involved in sorting the string SORTME using

More information

Part IV Other Systems: I Java Threads

Part IV Other Systems: I Java Threads Part IV Other Systems: I Java Threads Spring 2019 C is quirky, flawed, and an enormous success. 1 Dennis M. Ritchie Java Threads: 1/6 Java has two ways to create threads: Create a new class derived from

More information

Input from Files. Buffered Reader

Input from Files. Buffered Reader Input from Files Buffered Reader Input from files is always text. You can convert it to ints using Integer.parseInt() We use BufferedReaders to minimize the number of reads to the file. The Buffer reads

More information

S.E. Sem. III [CMPN] Object Oriented Programming Methodology

S.E. Sem. III [CMPN] Object Oriented Programming Methodology S.E. Sem. III [CMPN] Object Oriented Programming Methodology Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 80 Q.1(a) Write a program to calculate GCD of two numbers in java. [5] (A) import java.util.*;

More information

CS180 Review. Recitation Week 15

CS180 Review. Recitation Week 15 CS180 Review Recitation Week 15 Announcement Final exam will be held on Thursday(12/17) 8:00~10:00 AM The coverage is comprehensive Project 5 is graded. Check your score in Blackboard. Classes and Methods

More information

MYcsvtu Notes. Java Programming Lab Manual

MYcsvtu Notes. Java Programming Lab Manual Java Programming Lab Manual LIST OF EXPERIMENTS 1. Write a Program to add two numbers using Command Line Arguments. 2. Write a Program to find the factorial of a given number using while statement. 3.

More information

Multithreading Pearson Education, Inc. All rights reserved.

Multithreading Pearson Education, Inc. All rights reserved. 1 23 Multithreading 2 23.1 Introduction Multithreading Provides application with multiple threads of execution Allows programs to perform tasks concurrently Often requires programmer to synchronize threads

More information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

NITI NITI I PRIORITET

NITI NITI I PRIORITET NITI public class ThreadsTest { public static void main(string args[]) { BytePrinter bp1 = new BytePrinter(); BytePrinter bp2 = new BytePrinter(); BytePrinter bp3 = new BytePrinter(); bp1.start(); bp2.start();

More information

COMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors

COMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors COMP30112: Concurrency Topics 4.1: Concurrency Patterns - Monitors Howard Barringer Room KB2.20: email: Howard.Barringer@manchester.ac.uk February 2009 Outline Monitors FSP Models-to-Java Monitors Producers/Consumers

More information

Networking with java (socket programming) a brief study

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

Multithreaded OO. Questions:

Multithreaded OO. Questions: Multithreaded OO Questions: 1 1. What s the following Applet code snippet doing? Also, which statement is establishing the network connection? public void actionperformed( ActionEvent evt ) { try { String

More information

3. Remote Procedure Call

3. Remote Procedure Call 3. Remote Procedure Call Master II Software Engineering Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras imed@imed.ws Imed Bouchrika. Distributed Objects, Uni of Souk-Ahras

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 OOP THROUGH JAVA (Common to CT, CM and IF)

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 OOP THROUGH JAVA (Common to CT, CM and IF) TED (10)-3069 (REVISION-2010) Reg. No.. Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 OOP THROUGH JAVA (Common to CT, CM and IF) (Maximum marks: 100) [Time: 3 hours

More information

Web Server Project. Tom Kelliher, CS points, due May 4, 2011

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

Overview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1

Overview. Processes vs. Threads. Computation Abstractions. CMSC 433, Fall Michael Hicks 1 CMSC 433 Programming Language Technologies and Paradigms Spring 2003 Threads and Synchronization April 1, 2003 Overview What are threads? Thread scheduling, data races, and synchronization Thread mechanisms

More information

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines

More information

Assignment, part1: feedback and common mistakes. INFO-0010 Samuel HIARD

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

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

Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff Network Programming by Vlad Costel Ungureanu for Learn Stuff Java Network Protocols 2 Java Network Protocols 3 Addresses Innet4Address (32-bit) 85.122.23.145 - numeric pentalog.com symbolic Innet6Address

More information

GlobalLogic Technical Question Paper

GlobalLogic Technical Question Paper GlobalLogic Technical Question Paper What is the output of the following code when compiled and run? Select two correct answers. public class Question01 { public static void main(string[] args){ int y=0;

More information

Recitation: Loop Jul 7, 2008

Recitation: 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 information

6 COMPUTER PROGRAMMING

6 COMPUTER PROGRAMMING 6 COMPUTER PROGRAMMING ITERATION STATEMENT CONTENTS WHILE DO~WHILE FOR statement 2 Iteration Statement provides While / do-while / For statements for supporting an iteration logic function that the logic

More information

Advanced Java Programming. Networking

Advanced Java Programming. Networking Advanced Java Programming Networking Eran Werner and Ohad Barzilay Tel-Aviv University Advanced Java Programming, Spring 2006 1 Overview of networking Advanced Java Programming, Spring 2006 2 TCP/IP protocol

More information

Threads Chate Patanothai

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

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ IN & OUTPUT USING STREAMS 2 Streams streams are

More information

d. If a is false and b is false then the output is "ELSE" Answer?

d. If a is false and b is false then the output is ELSE Answer? Intermediate Level 1) Predict the output for the below code: public void foo( boolean a, boolean b) if( a ) System.out.println("A"); if(a && b) System.out.println( "A && B"); if (!b ) System.out.println(

More information

A sample print out is: is is -11 key entered was: w

A sample print out is: is is -11 key entered was: w Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void

More information

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

Distributed Systems. 3. Access to the Transport Layer. Werner Nutt Distributed Systems 3. Access to the Transport Layer Werner Nutt 1 Access to the Transport Layer Processes issue requests to the transport layer (i.e., the application takes the initiative, not the transport

More information

Java Programming Language Mr.Rungrote Phonkam

Java Programming Language Mr.Rungrote Phonkam 3 Java Programming Language Mr.Rungrote Phonkam rungrote@it.kmitl.ac.th Contents 1. Identify 2. Method Member 3. Literals 4. Data Type 6. Variable 1. Identify ก ก Class, Data, Method, Variable, Label,

More information

CSCD 330 Network Programming

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

Higher National Diploma in Information Technology First Year, Second Semester Examination 2015

Higher National Diploma in Information Technology First Year, Second Semester Examination 2015 [All Rights Reserved] SLIATE SRI LANKA INSTITUTE OF ADVANCED TECHNOLOGICAL EDUCATION (Established in the Ministry of Higher Education, vide in Act No. 29 of 1995) Higher National Diploma in Information

More information

1 (6) Lösningsförslag Objektorienterade applikationer Provdatum Program DAI 2 Läsår 2016/2017, lp 3. Uppgift 1 (1+1+1 p) a)

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