Download Expi2Java User Manual - Information Security and Cryptography

Transcript
1
( ∗ C o n f i g u r a t i o n o f t h e ” H e l l o World ” p r o t o c o l ∗ )
2
3
4
5
6
7
c o n f i g ChanA e x t e n d s T c p I p C h C f g ( ( ∗ c l i e n t ∗ )
variable
= ”cA” ,
host
= ” 1 2 7 . 0 . 0 . 1 ” , (∗ i p of the s e r v e r ∗)
port
= ” 1234 ”
).
8
9
10
11
12
13
c o n f i g ChanB e x t e n d s T c p I p C h C f g ( ( ∗ s e r v e r ∗ )
variable
= ”cB” ,
host
= ” any ” , ( ∗ l i s t e n s on a l l h o s t s ∗ )
port
= ” 1234 ”
).
14
15
c o n f i g Msg e x t e n d s U T F 8 S t r i n g C f g ( message = ” H e l l o World ! ! ! ” ) .
Listing 11: Final configuration: hello-world.exdef
Now we can generate a free name c of type ChannelhExpiStringi in the main process (so that it
is visible for both participants) and let it use the configurations we just created:
...
process
new c : Channel@ChanA<E x p i S t r i n g @ M s g >;
( pB | pA )
Listing 12: Creating a communication channel: hello-world.expi
This is only the client part of the channel, we need to reconfigure the channel after applying
the accept() destructor to model the server side. We do this in the named process pB:
l e t pB =
l e t c = a c c e p t [−>@ChanB ] ( c ) i n
0.
Listing 13: Channel on the server side: hello-world.expi
We proceed with the process pA by generating a new message name m of type ExpiString and
configuring it with the configuration Msg. Afterwards, we send the message m on the channel
c:
l e t pA =
new m : E x p i S t r i n g @ M s g ;
out ( c , m) .
Listing 14: Creating and sending the message: hello-world.expi
We receive the message in process pB:
l e t pB =
l e t c = a c c e p t [−>@ChanB ] ( c ) i n
i n ( c , m) .
Listing 15: Receiving the message: hello-world.expi
24