The Corrade UDP server is almost identical to the TCP server just that the server works over UDP. Compared to the TCP server, there are some differences imposed by the UDP protocol itself that leads to some differences that will be summarized here.
The main difference is that UDP is typically session-less, which means that there no "maintained connection" between a client connecting to Corrade just data that is being sent over endpoints. When a client sends data to the Corrade UDP server, Corrade stores the source port of the UDP client and its IP address in order to deliver notifications. The IP and port of the connecting client thus becomes a session tracker that is used for Corrade to track connections.
As an demonstration netcat can be used to connect to the Corrade UDP server:
nc -u -p 30000 192.168.2.1 8085
where:
-u
means that an UDP connection is requested instead of TCP,-p 30000
this specifies the source port,192.168.2.1
is the IP address of the machine that Corrade is running on,8085
is the port that the Corrade UDP server is running on
Once this command is issued and assuming that the Corrade UDP server is made to listen on the IP 192.168.2.1
and port 8085
, there are no packets exchanged yet so the command will sit and listen for some messages to be sent.
Just like the TCP server, the UDP server works both ways and can be used to receive notifications, send commands and also receive the callbacks to the commands over the same connection.
In order to subscribe to, say, the local
notification, the string is sent via netcat:
group=My Group&password=mypassword&type=local
identical to the TCP server.
From now on, Corrade will always send local chat to the client IP and port. Assuming that the client's IP address is 192.168.2.2
and the port specified by netcat is 30000
, the local
notification will be delivered from 192.168.2.1:8085
(Corrade) to the client 192.168.2.2:30000
(netcat):
192.168.2.1:8085 -> 192.168.2.2:30000
It is important to notice that "disconnecting" netcat does not make Corrade stop sending the local
notification to 192.168.2.2:30000
. In fact, netcat can be started again with the same command:
nc -u -p 30000 192.168.2.1 8085
and the local
notification data will be received without even having to authenticate. It is therefore important to maintain the connecting IP of the client and the source port (in this example 192.168.2.2:30000
) when "reconnecting" to the Corrade UDP server.
The UDP server supports re-requesting notifications, for example, were one to have requested the local
and message
notifications by sending the following string to the Corrade UDP server:
group=My Group&password=mypassword&type=local,message
it is then possible at any time to re-bind to any other notification, say, group chatter by simply sending the binding string again:
group=My Group&password=mypassword&type=group
This will make the UDP server stop sending local
and message
notifications and start sending group
notifications.
Using netcat, sending commands is as simple as opening a connection, for example, with netcat:
nc -u -p 30000 192.168.2.1 8085
where:
-u
means that an UDP connection is requested instead of TCP,-p 30000
this specifies the source port,192.168.2.1
is the IP address of the machine that Corrade is running on,8085
is the port that the Corrade UDP server is running onand then sending a typical command string:
command=version&group=My Group&password=mypassword
to which Corrade will reply with the result of the command.
Setting up certificates is identical to the TCP server. This will allow the connection to be encrypted between the client and the Corrade UDP server.