/* Source code made by iri This code is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. You can do what you want with it */ // BOB defcom commToAlice = funHello I S S;; // sent datas are an integer and two strings typeof chnToAlice = Chn;; // channel between Bob and Alice typeof server = Srv;; // server to receive all messages fun createServer ()= // we keep the current environment and open the port 3502. No script will be executed when a connection occurs (nil) set server = _setserver _envchannel _channel 3502 nil; _fooS if server == nil then "Unable to create a server, the port is probably busy" // Normally, we should find a free port number ... else "Server created"; 0;; fun main ()= _showconsole; _fooS "My name is BOB"; createServer; // Bob create his Scol server /* Now, we create a new channel from Bob to Alice The current environment will be put in the new channel */ let _envchannel _channel -> myEnv in set chnToAlice = _openchannel "127.0.0.1:3500" nil myEnv; if chnToAlice == nil then // error ( _fooS "Channel not created"; 0 ) else ( /* Next, we send our message to Alice in the channel to Alice ... Our message must respect the declared typing (defcom commToAlice = funHello I S S;;) A function '__funHello' should exist in Alice to examine this message. Otherwise, it will be ignored */ let _on chnToAlice commToAlice [10 "This is Bob !" "I come in 5 minutes"] -> result in _fooS if result == 0 then "send OK" // the message has been sent, that's all ! else "send KO"; 0 );; // Fonction called when a message is received from Alice (her reply) fun __reply (message)= _fooS message; 0;; // Fonction called when a message comes in the channel fun _connected ()= _fooS strcatn "New connection from IP " :: (_channelIP _channel) :: " port number " :: (itoa _channelport _channel) :: nil; 0;;