CS108, Stanford Handout #33. Sockets
|
|
|
- Scott Harper
- 9 years ago
- Views:
Transcription
1 CS108, Stanford Handout #33 Fall, Nick Parlante Sockets Sockets Sockets make network connections between machines, but you just read/write/block on them like there were plain file streams. The Internet is basically built on sockets. Client Socket Make connection to host name " " or "localhost" (the local machine itself) or "elaine26.stanford.edu" (machine on the internet) + a port number on that machine. - Socket toserver = new Socket(host, port); // make connection - OutputStream out = toserver.getoutputstream(); // write to this - InputStream in = toserver.getinputstream; // read from this Reads will block if there is no data (do not do on swing thread!) Writes go through fast, so ok to do on swing thread (could fork off a thread to do it) Can wrap each stream in ObjectInputStream/ObjectOutputStream to send whole objects, e.g. String, -- a low budget way to do network i/o without a lot of parsing, although not the most efficient. Server Sockets / accept() The server thread creates a sever socket and calls accept() to wait (block) for incoming client connections on a particular port number. On unix, ports under 1024 are "privileged" so regular users must use high port numbers, like 8000 or The accept() call blocks waiting for an incoming connection, and then returns a new socket, one for each incoming client. Typically you deal with the new connection, and then loop around and block in accept again. Get input and output streams, as above, for each client See the ServerAccepter example below. Blocking / Flushing Reading on a socket when there is no data will block -- so you can't do that on the swing thread Likewise, the server blocks in accept(), waiting for new client connections Writing on a socket may "buffer" the data to send it all in a big chunk. Use flush() on a stream to force the accumulated data to go out now. When you close() on a stream when you are done with it, that does an implicit flush() to send all the data. XMLString Strategy -- Writing Create an xml String representation of a Message object using encoder. Use WriteObject() to send the string on the socket. // Convert the message object into an xml string. OutputStream memstream = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(memStream); encoder.writeobject(message); encoder.close(); String xmlstring = memstream.tostring(); r XMLString Strategy -- Reading Use readobject() to get the string, then xml decoder to recreate the Message object.
2 2 // Get the xml string, decode to a Message object. String xmlstring = (String) in.readobject(); XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(xmlString.getBytes())); Message message = (Message) decoder.readobject(); Ticker GUI/Socket Example Message -- a little struct bean that contains a Date and a String Server button -> accepts client connections. Starts a ServerAccepter thread. Server keeps a list of all the connections to clients -- sends messages to all of them. Client button -> connects to a server and listens for incoming messages, posts them to its GUI. Complete code available in hw directory Ticker Example Code //TickerExample.java /* Demonstrates using client and server sockets with a GUI. One server ticker can support any number of client tickers -- sortof a primitive, one-way instant messenger. Uses xml encoding to send a little data struct Message object. */ import java.awt.*; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.beans.xmldecoder; import java.beans.xmlencoder; import javax.swing.*; import java.util.*; import java.io.*; import java.net.*; public class TickerExample extends JFrame { private JTextArea textarea; private JTextField field; private JLabel status; // The are thread inner classes to handle // the networking. private ClientHandler clienthandler; private ServerAccepter serveraccepter; // List of object streams to which we send data private java.util.list<objectoutputstream> outputs = new ArrayList<ObjectOutputStream>(); public static void main(string[] args) { // Prefer the "native" look and feel. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); catch (Exception ignored) { for (int i=0 ;i<3; i++ ) { // for testing, handy to make a few at a time new TickerExample(); public TickerExample() { settitle("ticker"); JComponent box = new JPanel(); box.setlayout(new BoxLayout(box, BoxLayout.Y_AXIS)); setcontentpane(box); textarea = new JTextArea(20, 20); add(new JScrollPane(textArea), BorderLayout.CENTER);
3 3 JButton button; button = new JButton("Start Server"); box.add(button); button.addactionlistener( new ActionListener() { public void actionperformed(actionevent e) { doserver(); ); button = new JButton("Start Client"); box.add(button); button.addactionlistener( new ActionListener() { public void actionperformed(actionevent e) { doclient(); ); field = new JTextField(15); JPanel panel = new JPanel(); panel.setminimumsize(new Dimension(200, 30)); panel.add(field); box.add(panel); field.addactionlistener( new ActionListener() { public void actionperformed(actionevent e) { dosend(); ); status = new JLabel(); box.add(status); setdefaultcloseoperation(jframe.exit_on_close); pack(); setvisible(true); // Struct object just used for communication -- sent on the object stream. // Declared "static", so does not contain a pointer to the outer object. // Bean style, set up for xml encode/decode. public static class Message { public String text; public Date date; public Message() { text = null; date = null; public String gettext() { return text; public void settext(string text) { this.text = text; public Date getdate() { return date; public void setdate(date date) { this.date = date; public String tostring() { return "message: " + text; // Appends a message to the local GUI (must be on swing thread) public void sendlocal(message message) {
4 4 textarea.settext(textarea.gettext() + message.gettext() + "\n" + message.getdate() + "\n\n"); // Initiate message send -- send both local annd remote (must be on swing thread) // Wired to text field. public void dosend() { Message message = new Message(); message.settext(field.gettext()); message.setdate(new Date()); sendlocal(message); sendremote(message); field.settext(""); // Client runs this to handle incoming messages // (our client only uses the inputstream of the connection) private class ClientHandler extends Thread { private String name; private int port; ClientHandler(String name, int port) { this.name = name; this.port = port; // Connect to the server, loop getting messages public void run() { // make connection to the server name/port Socket toserver = new Socket(name, port); // get input stream to read from server and wrap in object input stream ObjectInputStream in = new ObjectInputStream(toServer.getInputStream()); System.out.println("client: connected!"); // we could do this if we wanted to write to server in addition // to reading // out = new ObjectOutputStream(toServer.getOutputStream()); while (true) { // Get the xml string, decode to a Message object. // Blocks in readobject(), waiting for server to send something. String xmlstring = (String) in.readobject(); XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(xmlString.getBytes())); Message message = (Message) decoder.readobject(); System.out.println("client: read " + message); invoketogui(message); catch (Exception ex) { // IOException and ClassNotFoundException ex.printstacktrace(); // Could null out client ptr. // Note that exception breaks out of the while loop, // thus ending the thread. // Given a message, puts that message in the local GUI. // Can be called by any thread. public void invoketogui(message message) { final Message temp = message; SwingUtilities.invokeLater( new Runnable() { public void run() { status.settext("client receive"); sendlocal(temp); );
5 5 // Sends a message to all of the outgoing streams. // Writing rarely blocks, so doing this on the swing thread is ok, // although could fork off a worker to do it. public synchronized void sendremote(message message) { status.settext("server send"); System.out.println("server: send " + message); // Convert the message object into an xml string. OutputStream memstream = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(memStream); encoder.writeobject(message); encoder.close(); String xmlstring = memstream.tostring(); // Now write that xml string to all the clients. Iterator<ObjectOutputStream> it = outputs.iterator(); while (it.hasnext()) { ObjectOutputStream out = it.next(); out.writeobject(xmlstring); out.flush(); catch (Exception ex) { ex.printstacktrace(); it.remove(); // Cute use of iterator and exceptions -- // drop that socket from list if have probs with it // Adds an object stream to the list of outputs // (this and sendtooutputs() are synchronzied to avoid conflicts) public synchronized void addoutput(objectoutputstream out) { outputs.add(out); // Server thread accepts incoming client connections class ServerAccepter extends Thread { private int port; ServerAccepter(int port) { this.port = port; public void run() { ServerSocket serversocket = new ServerSocket(port); while (true) { Socket toclient = null; // this blocks, waiting for a Socket to the client toclient = serversocket.accept(); System.out.println("server: got client"); // Get an output stream to the client, and add it to // the list of outputs // (our server only uses the output stream of the connection) addoutput(new ObjectOutputStream(toClient.getOutputStream())); catch (IOException ex) { ex.printstacktrace(); // Starts the sever accepter to catch incoming client connections. // Wired to Server button. public void doserver() {
6 6 status.settext("start server"); String result = JOptionPane.showInputDialog("Run server on port", "8001"); if (result!=null) { System.out.println("server: start"); serveraccepter = new ServerAccepter(Integer.parseInt(result.trim())); serveraccepter.start(); // Runs a client handler to connect to a server. // Wired to Client button. public void doclient() { status.settext("start client"); String result = JOptionPane.showInputDialog("Connect to host:port", " :8001"); if (result!=null) { String[] parts = result.split(":"); System.out.println("client: start"); clienthandler = new ClientHandler(parts[0].trim(), Integer.parseInt(parts[1].trim())); clienthandler.start();
Advanced Network Programming Lab using Java. Angelos Stavrou
Advanced Network Programming Lab using Java Angelos Stavrou Table of Contents A simple Java Client...3 A simple Java Server...4 An advanced Java Client...5 An advanced Java Server...8 A Multi-threaded
Creating a Simple, Multithreaded Chat System with Java
Creating a Simple, Multithreaded Chat System with Java Introduction by George Crawford III In this edition of Objective Viewpoint, you will learn how to develop a simple chat system. The program will demonstrate
Homework/Program #5 Solutions
Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the
An Overview of Java. overview-1
An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2
Programming with Java GUI components
Programming with Java GUI components Java includes libraries to provide multi-platform support for Graphic User Interface objects. The multi-platform aspect of this is that you can write a program on a
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment exercises how to write a peer-to-peer communicating program using non-blocking
Question1-part2 What undesirable consequences might there be in having too long a DNS cache entry lifetime?
CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Working as a group. Working in small gruops of 2-4 students. When you work as a group, you have to return only one home assignment per
Network/Socket Programming in Java. Rajkumar Buyya
Network/Socket Programming in Java Rajkumar Buyya Elements of C-S Computing a client, a server, and network Client Request Result Network Server Client machine Server machine java.net Used to manage: URL
www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk
CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling
// Correntista. //Conta Corrente. package Banco; public class Correntista { String nome, sobrenome; int cpf;
// Correntista public class Correntista { String nome, sobrenome; int cpf; public Correntista(){ nome = "zé"; sobrenome = "Pereira"; cpf = 123456; public void setnome(string n){ nome = n; public void setsobrenome(string
file://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html
file:c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html Seite 1 von 5 ScanCmds.java ------------------------------------------------------------------------------- ScanCmds Demontration
Callbacks. Callbacks Copyright 2007 by Ken Slonneger 1
Callbacks Callbacks refer to a mechanism in which a library or utility class provides a service to clients that are unknown to it when it is defined. Suppose, for example, that a server class creates a
CS 335 Lecture 06 Java Programming GUI and Swing
CS 335 Lecture 06 Java Programming GUI and Swing Java: Basic GUI Components Swing component overview Event handling Inner classes and anonymous inner classes Examples and various components Layouts Panels
NETWORKING CHAPTER. Objectives
CHAPTER 33 NETWORKING Objectives To explain terms: TCP, IP, domain name, domain name server, streambased communications, and packet-based communications ( 33.2). To create servers using server sockets
Network Communication
Network Communication Outline Sockets Datagrams TCP/IP Client-Server model OSI Model Sockets Endpoint for bidirectional communication between two machines. To connect with each other, each of the client
INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 7: Object-Oriented Programming Introduction One of the key issues in programming is the reusability of code. Suppose that you have written a program
Application Development with TCP/IP. Brian S. Mitchell Drexel University
Application Development with TCP/IP Brian S. Mitchell Drexel University Agenda TCP/IP Application Development Environment Client/Server Computing with TCP/IP Sockets Port Numbers The TCP/IP Application
Java Network Programming. The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol).
Java Network Programming The java.net package contains the Socket class. This class speaks TCP (connection-oriented protocol). The DatagramSocket class uses UDP (connectionless protocol). The java.net.socket
The Java I/O System. Binary I/O streams (ascii, 8 bits) The decorator design pattern Character I/O streams (Unicode, 16 bits)
Binary I/O streams (ascii, 8 bits) InputStream OutputStream The Java I/O System The decorator design pattern Character I/O streams (Unicode, 16 bits) Reader Writer Comparing Binary I/O to Character I/O
Building a Multi-Threaded Web Server
Building a Multi-Threaded Web Server In this lab we will develop a Web server in two steps. In the end, you will have built a multi-threaded Web server that is capable of processing multiple simultaneous
Socket-based Network Communication in J2SE and J2ME
Socket-based Network Communication in J2SE and J2ME 1 C/C++ BSD Sockets in POSIX POSIX functions allow to access network connection in the same way as regular files: There are special functions for opening
Assignment 4 Solutions
CSCI 312 - DATA COMMUNICATIONS AND NETWORKS FALL, 2014 Assignment 4 Solutions Working as a pair Working in pairs. When you work as a pair you have to return only one home assignment per pair on a round.
Building a Java chat server
Building a Java chat server Presented by developerworks, your source for great tutorials Table of Contents If you're viewing this document online, you can click any of the topics below to link directly
Logging in Java Applications
Logging in Java Applications Logging provides a way to capture information about the operation of an application. Once captured, the information can be used for many purposes, but it is particularly useful
D06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch16 Files and Streams PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for
DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen
DHBW Karlsruhe, Vorlesung Programmieren, Remote Musterlösungen Aufgabe 1 RMI - TimeService public interface TimeServerInterface extends Remote { public String gettime() throws RemoteException; import java.util.date;
Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, 2015. To gain experience with Strings. Objective
Lab 9 Handout 11 CSCI 134: Spring, 2015 Spam, Spam, Spam Objective To gain experience with Strings. Before the mid-90s, Spam was a canned meat product. These days, the term spam means just one thing unwanted
http://netbeans.org/kb/docs/java/gui-functionality.html?print=yes
Page 1 of 6 Introduction to GUI Building Contributed by Saleem Gul and Tomas Pavek, maintained by Ruth Kusterer and Irina Filippova This beginner tutorial teaches you how to create a simple graphical user
AVRO - SERIALIZATION
http://www.tutorialspoint.com/avro/avro_serialization.htm AVRO - SERIALIZATION Copyright tutorialspoint.com What is Serialization? Serialization is the process of translating data structures or objects
Lesson: All About Sockets
All About Sockets http://java.sun.com/docs/books/tutorial/networking/sockets/index.html Page 1 sur 1 The Java TM Tutorial Start of Tutorial > Start of Trail Trail: Custom Networking Lesson: All About Sockets
WRITING DATA TO A BINARY FILE
WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.
GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012
GUIs with Swing Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2012 Slides copyright 2012 by Jeffrey Eppinger, Jonathan Aldrich, William
How To Build A Swing Program In Java.Java.Netbeans.Netcode.Com (For Windows) (For Linux) (Java) (Javax) (Windows) (Powerpoint) (Netbeans) (Sun) (
Chapter 11. Graphical User Interfaces To this point in the text, our programs have interacted with their users to two ways: The programs in Chapters 1-5, implemented in Processing, displayed graphical
!"# $ %!&' # &! ())*!$
!"# $ %!&' # &! ())*!$ !" #!$ %& ' ( ) * +,--!&"" $.!! /+010!" +!, 31! 4)&/0! $ #"5!! & + 6+ " 5 0 7 /&8-9%& ( +" 5)& /*#.! &( $ 1(" 5 # ( 8 +1 + # + 7$ (+!98 +&%& ( +!" (!+!/ (!-. 5 7 (! 7 1+1( & + ":!
What is an I/O Stream?
Java I/O Stream 1 Topics What is an I/O stream? Types of Streams Stream class hierarchy Control flow of an I/O operation using Streams Byte streams Character streams Buffered streams Standard I/O streams
Using A Frame for Output
Eventos Roteiro Frames Formatting Output Event Handling Entering Data Using Fields in a Frame Creating a Data Entry Field Using a Field Reading Data in an Event Handler Handling Multiple Button Events
Remote Method Invocation
Goal of RMI Remote Method Invocation Implement distributed objects. Have a program running on one machine invoke a method belonging to an object whose execution is performed on another machine. Remote
Division of Informatics, University of Edinburgh
CS1Bh Lecture Note 20 Client/server computing A modern computing environment consists of not just one computer, but several. When designing such an arrangement of computers it might at first seem that
Graphical User Interfaces
M14_REGE1813_02_SE_C14.qxd 2/10/10 3:43 PM Page 822 Chapter14 Graphical User Interfaces 14.1 GUI Basics Graphical Input and Output with Option Panes Working with Frames Buttons, Text Fields, and Labels
Learning Outcomes. Networking. Sockets. TCP/IP Networks. Hostnames and DNS TCP/IP
CP4044 Lecture 7 1 Networking Learning Outcomes To understand basic network terminology To be able to communicate using Telnet To be aware of some common network services To be able to implement client
Nexawebホワイトペーパー. Developing with Nexaweb ~ Nexaweb to Improve Development Productivity and Maintainability
Nexawebホワイトペーパー Developing with Nexaweb ~ Nexaweb to Improve Development Productivity and Maintainability Nexaweb Technologies, Inc. February 2012 Overview Many companies today are creating rich internet
CS 1302 Ch 19, Binary I/O
CS 1302 Ch 19, Binary I/O Sections Pages Review Questions Programming Exercises 19.1-19.4.1, 19.6-19.6 710-715, 724-729 Liang s Site any Sections 19.1 Introduction 1. An important part of programming is
Chapter 20 Streams and Binary Input/Output. Big Java Early Objects by Cay Horstmann Copyright 2014 by John Wiley & Sons. All rights reserved.
Chapter 20 Streams and Binary Input/Output Big Java Early Objects by Cay Horstmann Copyright 2014 by John Wiley & Sons. All rights reserved. 20.1 Readers, Writers, and Streams Two ways to store data: Text
GUI Event-Driven Programming
GUI Event-Driven Programming CSE 331 Software Design & Implementation Slides contain content by Hal Perkins and Michael Hotan 1 Outline User events and callbacks Event objects Event listeners Registering
Introduction to Java. Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233. ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1
Introduction to Java Module 12: Networking (Java Sockets) Prepared by Costantinos Costa for EPL 233 ΕΠΛ233 Αντικειμενοστρεφής Προγραμματισμός 1 What Is a Socket? A socket is one end-point of a two-way
An Android-based Instant Message Application
An Android-based Instant Message Application Qi Lai, Mao Zheng and Tom Gendreau Department of Computer Science University of Wisconsin - La Crosse La Crosse, WI 54601 [email protected] Abstract One of the
Java Appletek II. Applet GUI
THE INTERNET,mapped on the opposite page, is a scalefree network in that Java Appletek II. dis.'~tj port,from BYALBERTU\SZLOBARABASI ANDERICBONABEAU THE INTERNET,mapped on the opposite page, is a scalefree
INPUT AND OUTPUT STREAMS
INPUT AND OUTPUT The Java Platform supports different kinds of information sources and information sinks. A program may get data from an information source which may be a file on disk, a network connection,
Continuous Integration Part 2
1 Continuous Integration Part 2 This blog post is a follow up to my blog post Continuous Integration (CI), in which I described how to execute test cases in Code Tester (CT) in a CI environment. What I
TP1 : Correction. Rappels : Stream, Thread et Socket TCP
Université Paris 7 M1 II Protocoles réseaux TP1 : Correction Rappels : Stream, Thread et Socket TCP Tous les programmes seront écrits en Java. 1. (a) Ecrire une application qui lit des chaines au clavier
Socket Programming in Java
Socket Programming in Java Learning Objectives The InetAddress Class Using sockets TCP sockets Datagram Sockets Classes in java.net The core package java.net contains a number of classes that allow programmers
ICOM 4015: Advanced Programming
ICOM 4015: Advanced Programming Lecture 10 Reading: Chapter Ten: Inheritance Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter 10 Inheritance Chapter Goals To learn about inheritance To
Dev Articles 05/25/07 11:07:33
Java Crawling the Web with Java Contributed by McGraw Hill/Osborne 2005 06 09 Access Your PC from Anywhere Download Your Free Trial Take your office with you, wherever you go with GoToMyPC. It s the remote
Extending Desktop Applications to the Web
Extending Desktop Applications to the Web Arno Puder San Francisco State University Computer Science Department 1600 Holloway Avenue San Francisco, CA 94132 [email protected] Abstract. Web applications have
5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung
AWT vs. Swing AWT (Abstract Window Toolkit; Package java.awt) Benutzt Steuerelemente des darunterliegenden Betriebssystems Native Code (direkt für die Maschine geschrieben, keine VM); schnell Aussehen
Threads & Tasks: Executor Framework
Threads & Tasks: Executor Framework Introduction & Motivation WebServer Executor Framework Callable and Future 12 April 2012 1 Threads & Tasks Motivations for using threads Actor-based Goal: Create an
Tutorial Reference Manual. Java WireFusion 4.1
Tutorial Reference Manual Java WireFusion 4.1 Contents INTRODUCTION...1 About this Manual...2 REQUIREMENTS...3 User Requirements...3 System Requirements...3 SHORTCUTS...4 DEVELOPMENT ENVIRONMENT...5 Menu
Socket programming. Complement for the programming assignment INFO-0010
Socket programming Complement for the programming assignment INFO-0010 Outline Socket definition Briefing on the Socket API A simple example in Java Multi-threading and Synchronization HTTP protocol Debugging
Java Programming: Sockets in Java
Java Programming: Sockets in Java Manuel Oriol May 10, 2007 1 Introduction Network programming is probably one of the features that is most used in the current world. As soon as people want to send or
StreamServe Persuasion SP4 Service Broker
StreamServe Persuasion SP4 Service Broker User Guide Rev A StreamServe Persuasion SP4 Service Broker User Guide Rev A 2001-2009 STREAMSERVE, INC. ALL RIGHTS RESERVED United States patent #7,127,520 No
DC60 JAVA AND WEB PROGRAMMING JUNE 2014. b. Explain the meaning of the following statement public static void main (string args [ ] )
Q.2 a. How does Java differ from C and C++? Page 16 of Text Book 1 b. Explain the meaning of the following statement public static void main (string args [ ] ) Page 26 of Text Book 1 Q.3 a. What are the
How Scala Improved Our Java
How Scala Improved Our Java Sam Reid PhET Interactive Simulations University of Colorado http://spot.colorado.edu/~reids/ PhET Interactive Simulations Provides free, open source educational science simulations
Lab 4: Socket Programming: netcat part
Lab 4: Socket Programming: netcat part Overview The goal of this lab is to familiarize yourself with application level programming with sockets, specifically stream or TCP sockets, by implementing a client/server
Swing. A Quick Tutorial on Programming Swing Applications
Swing A Quick Tutorial on Programming Swing Applications 1 MVC Model View Controller Swing is based on this design pattern It means separating the implementation of an application into layers or components:
Java Network. Slides prepared by : Farzana Rahman
Java Network Programming 1 Important Java Packages java.net java.io java.rmi java.security java.lang TCP/IP networking I/O streams & utilities Remote Method Invocation Security policies Threading classes
Mail User Agent Project
Mail User Agent Project Tom Kelliher, CS 325 100 points, due May 4, 2011 Introduction (From Kurose & Ross, 4th ed.) In this project you will implement a mail user agent (MUA) that sends mail to other users.
The difference between TCP/IP, UDP/IP and Multicast sockets. How servers and clients communicate over sockets
Network Programming Topics in this section include: What a socket is What you can do with a socket The difference between TCP/IP, UDP/IP and Multicast sockets How servers and clients communicate over sockets
Essentials of the Java(TM) Programming Language, Part 1
Essentials of the Java(TM) Programming Language, Part 1 http://developer.java.sun.com/developer...ining/programming/basicjava1/index.html Training Index Essentials of the Java TM Programming Language:
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
public static void main(string[] args) { System.out.println("hello, world"); } }
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).
The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,
11. Applets, normal window applications, packaging and sharing your work
11. Applets, normal window applications, packaging and sharing your work In this chapter Converting Full Screen experiments into normal window applications, Packaging and sharing applications packaging
Lösningsförslag till tentamen 121217
Uppgift 1 Lösningsförslag till tentamen 121217 a) Utskriften blir: a = 5 och b = 10 a = 5 och b = 10 b) Utskriften blir 1 2 3 4 5 5 2 3 4 1 c) Utskriften blir 321 Uppgift 2 Med användning av dialogrutor:
Lecture 7: Class design for security
Lecture topics Class design for security Visibility of classes, fields, and methods Implications of using inner classes Mutability Design for sending objects across JVMs (serialization) Visibility modifiers
public class neurale extends JFrame implements NeuralNetListener {
/* questo file contiene le funzioni che permettono la gestione della rete neurale. In particolare qui si implementa la fase di apprendimento e di addestramento. */ package neurofuzzy; import org.joone.engine.*;
JAVA - FILES AND I/O
http://www.tutorialspoint.com/java/java_files_io.htm JAVA - FILES AND I/O Copyright tutorialspoint.com The java.io package contains nearly every class you might ever need to perform input and output I/O
JAVA Program For Processing SMS Messages
JAVA Program For Processing SMS Messages Krishna Akkulu The paper describes the Java program implemented for the MultiModem GPRS wireless modem. The MultiModem offers standards-based quad-band GSM/GPRS
How To Write A Program For The Web In Java (Java)
21 Applets and Web Programming As noted in Chapter 2, although Java is a general purpose programming language that can be used to create almost any type of computer program, much of the excitement surrounding
Getting Started with the Internet Communications Engine
Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2
Principles of Software Construction: Objects, Design and Concurrency. GUIs with Swing. toad 15-214. Spring 2013
Principles of Software Construction: Objects, Design and Concurrency GUIs with Swing 15-214 toad Spring 2013 Christian Kästner Charlie Garrod School of Computer Science 2012-13 C Garrod, C Kästner, J Aldrich,
Chulalongkorn University International School of Engineering Department of Computer Engineering 2140105 Computer Programming Lab.
Chulalongkorn University Name International School of Engineering Student ID Department of Computer Engineering Station No. 2140105 Computer Programming Lab. Date Lab 2 Using Java API documents, command
About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. AVRO Tutorial
i About the Tutorial Apache Avro is a language-neutral data serialization system, developed by Doug Cutting, the father of Hadoop. This is a brief tutorial that provides an overview of how to set up Avro
Sample CSE8A midterm Multiple Choice (circle one)
Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names
! "# $%&'( ) * ).) "%&' 1* ( %&' ! "%&'2 (! ""$ 1! ""3($
! "# $%&'( ) * +,'-( ).) /"0'" 1 %&' 1* ( %&' "%&'! "%&'2 (! ""$ 1! ""3($ 2 ', '%&' 2 , 3, 4( 4 %&'( 2(! ""$ -5%&'* -2%&'(* ) * %&' 2! ""$ -*! " 4 , - %&' 3( #5! " 5, '56! "* * 4(%&'(! ""$ 3(#! " 42/7'89.:&!
Agenda. Network Programming and Java Sockets. Introduction. Internet Applications Serving Local and Remote Users
Programming and Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering University of Melbourne, Australia http://www.cs.mu.oz.au/~raj
CISC 4700 L01 Network & Client- Server Programming Spring 2016. Harold, Chapter 8: Sockets for Clients
CISC 4700 L01 Network & Client- Server Programming Spring 2016 Harold, Chapter 8: Sockets for Clients Datagram: Internet data packet Header: accounting info (e.g., address, port of source and dest) Payload:
Karsten Lentzsch JGoodies SWING WITH STYLE
Karsten Lentzsch JGoodies SWING WITH STYLE JGoodies: Karsten Lentzsch Open source Swing libraries Example applications Consultant for Java desktop Design assistance Training for visual design and implementation
NETWORK PROGRAMMING IN JAVA USING SOCKETS
NETWORK PROGRAMMING IN JAVA USING SOCKETS Prerna Malik, Poonam Rawat Student, Dronacharya College of Engineering, Gurgaon, India Abstract- Network programming refers to writing programs that could be processed
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
File I/O - Chapter 10. Many Stream Classes. Text Files vs Binary Files
File I/O - Chapter 10 A Java stream is a sequence of bytes. An InputStream can read from a file the console (System.in) a network socket an array of bytes in memory a StringBuffer a pipe, which is an OutputStream
Web Services (2009-10-29 1.1 )
Web Services Web Services What is a Web Service? It is an application component that can be accessed using Web protocols and data encoding mechanisms such as HTTP and XML. In our context the application
Skills and Topics for TeenCoder: Java Programming
Skills and Topics for TeenCoder: Java Programming Our Self-Study Approach Our courses are self-study and can be completed on the student's own computer, at their own pace. You can steer your student in
Manual. Programmer's Guide for Java API
2013-02-01 1 (15) Programmer's Guide for Java API Description This document describes how to develop Content Gateway services with Java API. TS1209243890 1.0 Company information TeliaSonera Finland Oyj
D06 PROGRAMMING with JAVA
Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch11 Interfaces & Polymorphism PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com,
Syllabus for CS 134 Java Programming
- Java Programming Syllabus Page 1 Syllabus for CS 134 Java Programming Computer Science Course Catalog 2000-2001: This course is an introduction to objectoriented programming using the Java language.
