Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IdUDPServer issue
#1
I use an IdUDPServer to open multiple Ports like this:
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
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
---
Bart Kindt
CEO and Developer
SARTrack Limited
New Zealand
www.sartrack.nz
Reply


Messages In This Thread
IdUDPServer issue - by BartKindt - 11-12-2018, 07:03 PM
RE: IdUDPServer issue - by rlebeau - 11-13-2018, 07:29 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)