Change IP address of the connection

delphi
(Marcos Cunha Lima) #1

Hi

Is there a way to change IP or Port of the server at the client? For instance, we are trying to code a server in which all configuration would be set by a client. When it is up, it assumes an IP default (127.0.0.1) and port default (8099).
Then, a client connects and changes all settings including IP or Port. I know that this could close the connection but I am struggling to do that as it seems that the server freezes.

The server change code is:

// self.FPort is the changed port
FROServer.Port := self.FPort;
if self.FIP <> '' then begin
   FRoServer.IndyServer.Bindings.Clear;
   socket := FRoServer.IndyServer.Bindings.Add;
   socket.IP := self.FIP;
   socket.Port := self.FPort;
 end;
0 Likes

(Marcos Cunha Lima) #2

I am using Delphi and TRoIndyHttpServer

0 Likes

(estebanp) #3

Hi,

I will recommend to have an additional port listening to those configuration changes and any other administrative purposes.

Also, make sure you close the server connection and if possible prior to that send a signal to all clients so they initiate a proper shutdown process on the client side.

Then open the connection with the new port settings.

0 Likes

(Marcos Cunha Lima) #4

Hi

Yes, I’m using one administrative port and it works very well to do every configuration. The problem is that what user will try to do is to change this administrative port. Is there a way to change the port that we are using to connect to other (even loosing the connection but doing the change at server and refreshing client later)?

0 Likes

(Marcos Cunha Lima) #5

Anyway, I’ve found out a way: when I change IP or Port of the server, I use administrative connection to change it and when I need to change administrative IP or Port, I use normal connection.

0 Likes