καλαθάκης γιώργης συλλογή ασκήσεων άλγεβρας β' λυκείου (Mathematica.gr)
03_ΣΔΥ50 - ΟΣΣ3 - Εκφωνήσεις Ασκήσεων
Transcript of 03_ΣΔΥ50 - ΟΣΣ3 - Εκφωνήσεις Ασκήσεων
-
7/25/2019 03_50 - 3 -
1/6
50
- 1 -
3
1. Java Sockets
)Echo service
Java 4.5 4.6
(www.cdk5.net/ipc)
echo TCP streams.
M javac command line
client (TCPClient.java) server (TCPServer.java).
server client.
:
java TCPServer
java TCPClient Hello SDY50 Tomos Blocalhost
server IP
port number / .
) Knock KncokWhos there?
Knock Kncok Whos there
(http://en.wikipedia.org/wiki/Knock-knock_joke)
- Java sockets.
To ( )
(). :
: Knock, knock!
: Who's there?
: (.. Atch)
: ; (.. Atch who?)
: (..Bless you!)
()
.
, ,
http://www.cdk5.net/ipchttp://www.cdk5.net/ipchttp://www.cdk5.net/ipchttp://en.wikipedia.org/wiki/Knock-knock_jokehttp://en.wikipedia.org/wiki/Knock-knock_jokehttp://en.wikipedia.org/wiki/Knock-knock_jokehttp://en.wikipedia.org/wiki/Knock-knock_jokehttp://www.cdk5.net/ipc -
7/25/2019 03_50 - 3 -
2/6
50
- 2 -
Bye. .
.
, Client,
TCPClient . Client
( {localhost, 5050})
.
Client socket server
socket / Java, streams
(.. BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in))
While( socket stream != null)
Begin
Bye. to loop
socket stream
EndWhile
KKServer Protocol.
Server
.
KKServer
listening socket While(true)
Begin
socket accept
I/O Java, streams
Protocol
output = processInput(null) // Protocol
(output)
While (input = socket stream != null)
-
7/25/2019 03_50 - 3 -
3/6
50
- 3 -
Begin
output = processInput(input)
(output)
output = Bye. to loop
EndWhile
EndWhile
. H
processInput Protocol.
( 1).
(input)
(output)
.
AWAIT
KNOCK_
KNOCK_
SENT
NAME_
SENT
[input==null]/
outpout="Knock! Knock!"
[input=="Who's there?"]/
outpout=names[currentRound]
[input!="Who's there?"]/
outpout= +"Knock! Knock!"
MORE
[input==names[currentRound]+" who?"]/
outpout=punch_line[currentRound] +
"Want more? (y/n)"
[input!=names[currentRound]+"who?"]/
outpout=+"Knock!Knock!"
[input=="y
"]/
outpout="K
nock!Kno
ck!"
currentRo
und+=%M
AX
[input!="y"]/outpout="Bye."
1.
:
private String[] names = { "You", "DNT", "Atch", "Who", "Who" };
private String[] punch_line = { "Did you call?",
"Your DeNTist! I wont hurt you!",
"Bless you!",
"Is there an owl in here?",
"Is there an echo in here?" };
-
7/25/2019 03_50 - 3 -
4/6
50
- 4 -
-
http://joke5.co.uk/joke/Category:Knock_Knock_Jokes
:
JAVA API TCP streams
Java.
1 KKProtocol.
:
.
, (threads)
.
:
KKServer threads
While(true)
Begin
thread
EndWhile
To thread
(Server).
.
2. Distributed Objects and Remote Invocation
(interface) Election :
vote: , (string)
(integer).
.
result:
.
http://joke5.co.uk/joke/Category:Knock_Knock_Jokeshttp://joke5.co.uk/joke/Category:Knock_Knock_Jokeshttp://joke5.co.uk/joke/Category:Knock_Knock_Jokes -
7/25/2019 03_50 - 3 -
5/6
50
- 5 -
:
) input output;
) Election Java RMI.
) Election
.
Election (Maybe invocation, At-Least-OnceInvocation, At-Most-Once Invocation);
) Election
.
) Election
.
).
3.
(threads)
) threads, ,
;
) file server caching (hit ratio)
80%. sever 5 ms CPU time,
caching , 15 ms / .
server (
/sec), :i) server (single-threaded)
ii) o server -
iii) server
4.
web-based .
.
:
-
7/25/2019 03_50 - 3 -
6/6
50
- 6 -
(entry ticket) (
)
(
)
( ,
, , ,),
.
,
(web service provider)
.
5.
Pastry
(P2P) ,
(overlay routing) Pastry,
b=4 ( GUIDs) L=8 . GUID:
65a1fc D: e232fc, :
GUIDs 4
; ( ?)
;
( Figure 10.6 Distributed
Systems)