VB.net vs Python

RIOTOUS previously used VB.net as the server-side language but due to current technical difficulties it has now shifted towards Python. While VB.net still works and there is a VB.net server for version 0.3 it does not support encryption. If encryption is needed, then Python must be used otherwise VB.net can be used. Future versions of RIOTOUS are expected to integrate encryption into VB.net.

Data communication

It should be stated that RIOTOUS uses a byte protocol and therefore any data sent must be an ASCII character. If numbers are needed to be sent then they must be converted to a string so if for example 0x00 needed to be sent then the string “0x00” or “0” could be sent.


Python Server

The first step when using RIOTOUS is to create a RIOTOUS object and pass it a Boolean variable. If this value is set to true then the server will use TEA encryption otherwise the server will not use encryption. After creating a server object .startThread() needs to be called. At this point the server will start and RIOTOUS devices can connect.


riotous_server = server(False)
riotous_server.startThread()

 


VB.net

While RIOTOUS can operate with most servers it is mainly designed to operate with a RIOTOUS server. The server side code handles data transfers, client connections, timeouts, and port assigning while keeping every connected client in its own thread. Only a few functions are needed to be called by the user to start the server and once started, only a few functions are needed to send and receive data to and from clients. Since the RIOTOUS server code is a VB.net class, you can use any project type including forms, command line, and even an XNA project if desired.

Server Class

The first task in creating a RIOTOUS server is creating an instance of the server class. Two files require to be imported into you project; Server.vb and client.vb. Server.vb contains the server class itself while client.vb contains the client class which is called by the server. Below is the code needed to create an instance of the RIOTOUS server.


Dim RIOTOUS As riotous_Server
RIOTOUS = New riotous_Server

With the server instance created, the server needs to be started. This is done by calling the function startServer and passing two arguments; the IP address of the machine executing the server, and the port that the server will advertise on.


RIOTOUS.startServer("192.168.0.1", "333")

While you may choose any port to advertise the server on it is best to use 333 as its a commonly unused port. Once the server starts, it will await for device connections and once a device connects, the server will find a free port slot (starting from 60000 upward), tell the client which port to reconnect to, and then close the connection.