11-12-2018, 07:03 PM
I use an IdUDPServer to open multiple Ports like this:
Then I set Active to TRUE.
Afterwards I got an exception caused by the other side: , UDPServer Exception: Socket Error # 10054Connection reset by peer.
I then call IdUDPServer1.Active := false; and I completely FreeAndNil it.
Then the loop starts again from fresh, with a newly created UDPServer.
However, now I get the Exception: Could not bind socket. Address and port are already in use
Why does this happen? Should I somehow manually clear the sockets before setting the Active to False?
Bart
Code:
IdUDPServer1.Active := false;
Socket1 := IdUDPServer1.Bindings.Add;
Socket1.IPVersion := Id_IPv4;
Socket1.IP := HyteraSettings.TCPLocalIP;
Socket1.Port := HyteraSettings.RRSPort; // RRS PORT
if HyteraSettings.Debug then LocalLog('UDPServer Bindings.Add: '+HyteraSettings.TCPLocalIP+' Port '+IntToStr(HyteraSettings.GPSPort));
Socket1 := IdUDPServer1.Bindings.Add;
Socket1.IPVersion := Id_IPv4;
Socket1.IP := HyteraSettings.TCPLocalIP;
Socket1.Port := HyteraSettings.GPSPort; // GPS PORT
Afterwards I got an exception caused by the other side: , UDPServer Exception: Socket Error # 10054Connection reset by peer.
I then call IdUDPServer1.Active := false; and I completely FreeAndNil it.
Then the loop starts again from fresh, with a newly created UDPServer.
However, now I get the Exception: Could not bind socket. Address and port are already in use
Why does this happen? Should I somehow manually clear the sockets before setting the Active to False?
Bart