Sockets and Dials

From Onix OS Wiki
Jump to: navigation, search

Dial functions can automatically initiate a socket or provide socket access and automatically communicate over a socket.


sock ...socket definitions...
dial_service(...defined socket, ...message definitions)
dial_send(...defined socket, ...message string)
# => ....result

We have two functions. Someone allows us to define a message to the defined socket. The other is connecting to the defined socket and transferring messages. We learned to define socket in the Definitions section. dial_service () converts the socket dialup to service as if it were a connection. with "dial_send()" we can send a message to socket and process the results.


Dial Server Example (dial_serve.ola)

sock socket “tcp4” “9050” “”; 
def messages = { 
   “ping”: “pong”, 
   “call”: “Calling… NOPE! :)”, 
   “help”: “Not helpfull!” 
dial_service(socket, messages)

# => The 9050 port is ready to connect.

Dial Client Example (dial_client.ol)

sock socket "tcp4" "9050" "";
def send = fn(message){
  println(dial_send(socket, message))
# => Calling... NOPE! :)
# => Not helpfull!

The example of this section is an excerpt from the "System Oriented Functional Programming Language (SOFPL)" page. 9050 port to a socket and this socket as a simple example we defined the system as a dialup service example by introducing a client after I have sent two messages to this port and connect.