Distributed programming: Difference between revisions

Factor implementation
(Factor implementation)
Line 468:
connecting to "srv@agneyam"
Received hi
 
=={{header|Factor}}==
The protocol is the one provided by Factor (concurrency.distributed, concurrency.messaging)
 
Example summary:
 
- A server node is listening for messages made of natural data types and structures, and simply prettyprint them.
 
- A client node is sending such data structure: an array of one string and one hashtable (with one key/value pair).
 
===Server===
<lang factor>USING: concurrency.distributed concurrency.messaging threads io.sockets io.servers ;
QUALIFIED: concurrency.messaging
: prettyprint-message ( -- ) concurrency.messaging:receive . flush prettyprint-message ;
[ prettyprint-message ] "logger" spawn dup name>> register-remote-thread
"127.0.0.1" 9000 <inet4> <node-server> start-server</lang>
 
===Client===
<lang factor>USING: concurrency.distributed io.sockets ;
QUALIFIED: concurrency.messaging
{ "Hello Remote Factor!" H{ { "key1" "value1" } } }
"127.0.0.1" 9000 <inet4> "logger" <remote-thread> concurrency.messaging:send</lang>
 
How to Run:
 
- Copy/Paste the server code in an instance of Factor Listener
 
- Copy/Paste the client code in another instance of Factor Listener.
 
The server node should prettyprint the data structure send by the client: { "Hello Remote Factor!" H{ { "key1" "value1" } } }
 
=={{header|Go}}==