3 DistFramework(session
:Session
)
6 Pickle(pack
:Pack unpack
:Unpack
)
7 SerializationUtils(toAlpha
:ToAlpha
8 completeTokens
:CompleteTokens
)
13 class SocketConnection
21 {@s
write(vs
:{ToAlpha
{Pack Here
} ","})}
28 {@s
read(list
:S size
:all
)}
33 {CompleteTokens S
","}
38 for m(From To Msg
) in Msgs
.2 do
39 {@d
deliver(From To Msg
)}
43 meth reg(DeliverFacet
)
46 meth send(From To Msg
)
47 M
={Pack
m(From To Msg
)} in
49 {@s
write(vs
:{ToAlpha M
","})}
61 {@d
connection(remove
self)}
69 fun{ProviderIP LM ?Uri
}
70 Process
={{LM
getLayer('dist
-layer
:process' $
)} init()}
72 Uri
='address
-provider
:IPSocket'
79 s
:={New Open
.socket
init()}
80 {@s
bind(port
:PortNr
)}
82 Address
=a(layer
:'address
-client
:IPSocket'
83 hosts
:{OS
.uName
}.nodename|
85 {OS
.getHostByName
{OS
.uName
}.nodename
}.addrList
86 {OS
.getHostByName
"localhost"}.addrList
93 S
={@s
accept(acceptClass
:Open
.socket accepted
:$
)} in
94 {Process
connection(add
{New SocketConnection
init(S
{Process
here($
)})} Sync
)}
96 catch _
then %e.g. Too many open connections
104 {Process
address(add Address Sync
)}
109 fun{ClientIP LM ?Uri
}
110 P
={{LM
getLayer('dist
-layer
:process' $
)} init()}
112 Uri
='address
-client
:IPSocket'
115 Done
={NewCell
false} in
121 S
={New Open
.socket
client(host
:H port
:A
.port
)}
122 Conn
={New SocketConnection
init(S
{P
here($
)})}
124 if {Conn
getProcess($
)}.id
=={Process
thisProcess($
)}.id
then
125 {Process
connection(add Conn
)}