How to Create Mutiple Instance of a Single EXE??

  • Thread starter Thread starter varadha
  • Start date Start date
V

varadha

Hi,

My Application listening to a port of my machine and
it response with data to the requesting system. This
application is provided as a service in my machine.
Now i am planning to have more than one instance of
this application listening to the input request.How
sholuld create multiple instance of the application.Is is
possible to have same port for listening for all the
instances.

Thanks in advance,
Varadha
 
varadha said:
My Application listening to a port of my machine and
it response with data to the requesting system. This
application is provided as a service in my machine.
Now i am planning to have more than one instance of
this application listening to the input request.How
sholuld create multiple instance of the application.Is is
possible to have same port for listening for all the
instances.

I don't think this is what you want to do - because if you have two
executables you will have two bind calls and the second one will fail
because the port is in use.

What you want to do is multi thread your application like this (paramaters
not included)

bind();
while (1){
i = accept();
if (i >0)
spawn_thread_to_handle_request(i);
}

This way - as soon as a request comes into your server - a new thread will
be spawned to handle the request - and the loop will spin around again to
the blocking accept() call and hang there waiting for another request.

Hope this clarifies things for you.
FJM..
 
Back
Top