Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdTCP(CMD)Server bindings
#1
I have a hunch I already know the answer to this..

Is there a way to change the bindings while the server is running?

I'd like to be able to send a command to my server and have it bind to another port and accept a connection there - but only when instructed to do so. After use, I'd like that binding to vanish and it stop listening there.

I know the bindings are usually taken care off in the Active property but can it be managed outside of this?
Reply
#2
(12-13-2024, 10:44 PM)Justin Case Wrote: Is there a way to change the bindings while the server is running?

Not officially, no. And this is the wrong approach for your situation anyway.

(12-13-2024, 10:44 PM)Justin Case Wrote: I'd like to be able to send a command to my server and have it bind to another port and accept a connection there - but only when instructed to do so. After use, I'd like that binding to vanish and it stop listening there.

I would suggest a different approach - have your command handler create a new TIdSimpleServer object, which is designed for 1:1 connections. Have it Listen() on the desired port, then you can communicate with the accepted connection via its IOHandler as needed, and then you can free it when finished.  There is no need to manipulate the main server.

Have a look at the implementation of the TIdFTP and TIdFTPServer components. They both use TIdSimpleServer internally when creating secondary inbound connections - TIdFTP during an active mode transfer, and TIdFTPServer during a passive mode transfer.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)