-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestnodesetserver.oz
41 lines (40 loc) · 1011 Bytes
/
testnodesetserver.oz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
declare
NS
FileO = {New Open.file init(name:'Grammars/diss.nodeset.xml' flags:[read])}
{FileO read(list:NS size:all)}
{FileO close}
class SocketK from Open.socket end
proc {Server PortI}
ServerO = {New SocketK init}
in
{ServerO bind(takePort:PortI)}
{ServerO listen}
for do
ClientO = {ServerO accept(accepted:$ acceptClass:SocketK)}
in
thread
{Inspect 'client accepted'}
S = {ClientO read(list:$ size:all)}
{Inspect 'server read '#{VirtualString.toAtom S}}
in
{ClientO write(vs:NS)}
{ClientO shutDown(how:[send])}
end
end
end
PortI = 4712
thread {Server PortI} end
{Inspect 'node set server is running'}
declare
fun {InitClient}
ClientO = {New SocketK init}
{ClientO connect(host:localhost port:PortI)}
in
ClientO
end
ClientO = {InitClient}
{ClientO write(vs:"mary_L+H*_LH% sees the man with a telescope_H*_LL% .")}
{ClientO shutDown(how:[send])}
V = {ClientO read(list:$ size:all)}
{Inspect 'client read '#{VirtualString.toAtom V}}
{ClientO close}