Java Client Server - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Java Client Server

Description:

Sqr root (Value is 100) = 10. Final answer = 10. Initial estimate ... Command ipconfig/all or use wincfg. Answer is printed on screen. Example nrserv.java ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 9
Provided by: cs03
Category:
Tags: client | ipconfig | java | server

less

Transcript and Presenter's Notes

Title: Java Client Server


1
Java Client Server

2
Example
  • Iterative function - Newton Raphson
  • Used to calculate a square root
  • estnew is a native float
  • estnew (estold Value/estold)/2
  • Sqr root (Value is 100) 10
  • Final answer 10
  • Initial estimate - estold 1000

3
Example bgnd cont.
  • estnew (estold Value/estold)/2
  • estnew (1000100/1000)/2500
  • estnew (500100/500)/2250 etc
  • Calc needs estold and Value
  • During run client sends strings
  • Text command - run Value est
  • nrserv sends back - ansnew

4
Example client.java
  • Network client.java
  • Works with nsrerv.java
  • Uses sockets
  • Input stream inpstr
  • Output stream outstr
  • sock new Socket
  • (157.228.x.x, 4444)

5
Example continued.
  • Server makes all calculations
  • Outval 100
  • Outstr.println(outval)
  • Iterate - ansoldansnew
  • Edit IP address connect to server
  • Command ipconfig/all or use wincfg
  • Answer is printed on screen

6
Example nrserv.java
  • Server accepts sock when
  • Client connects
  • Worker thread created
  • class Worker extends Thread
  • new Worker( sock ).start()
  • Method run() is invoked
  • Remember inputs to server - strings

7
Example continued
  • To read string convert to integer
  • valstrg inpstr.readline()
  • Value Integer.parseInt(valstrg)
  • Wrapper classes
  • Lower case float normal native float
  • Upper case Float denotes
  • Special class/object with methods wrapped around

8
Example continued
  • To read and convert string to float
  • Float temp Float.valueOf(eststrg)
  • float estold temp.floatValue()
  • This is special feature of Java
  • Input - Ctrlstrg valstrg eststrg
  • Uses ctrlstrg - Value(int) - estold(float)
  • Output value for client estout
Write a Comment
User Comments (0)
About PowerShow.com