I can’t figure out how to send data from UDPSocket2 to UDPSocket1.
Window1:
[code]Sub Open()
UDPSocket1.Port = 5566
UDPSocket1.Connect // Listen on Port 5566 for data
End Sub
[/code]
UDPSocket1.DataAvailable:
Sub DataAvailable()
Dim MyDatagram As Datagram
MyDatagram = me.Read
Listbox1.AddRow "Data: " + MyDatagram.Data // Display any data received.
End Sub
Sub Action()
If UDPSocket2.IsConnected = False Then
UDPSocket2.Port = 5566
UDPSocket2.Connect // Connect to send data.
End If
UDPSocket2.Write "192.168.1.111", "Hello world." // Send data to listening socket UDPSocket2
End Sub
Errors received:
105 AddressInUseError The address is currently in use.
This error will occur if you attempt to bind to a port that you have already bound to. An example of this would be setting up two listening sockets to try to listen on the same port.
106 InvalidStateError This is an invalid state error, which means that the socket is not in the proper state to be doing a certain operation.
An example of this is calling the Write method before the socket is actually connected.
I am able to do this in another language, so it seems as though it should be possible.
It would be disappointing to find out that this is a limitation regarding how UDPSockets are implemented in Xojo, if that is the case.