Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

How to synchronize apps running?

Thread view: 
masterwally@gmail.com - 18 Oct 2007 15:47 GMT
Hello,

I have a following issue: I have a application, that binds the two
other programs together in a way, that it runs them one after the
other. The issue is, that the first one is an application that opens a
number of sockets and waits for the incoming connections. The second
application connects to those sockets, transmits something and closes.
The thing is, that the first application is a Java app, while the
second one is native. And, before the first application is able to
start and open sockets, the second one runs, tries to connect, fails
and exits. I don't have any influence on that, I can only modify
sources of the first application and the "master" one. Do you have
some ideas on a nice way how master application can delay execution of
the second program? I must only say, that "sleep" is insufficient, as
I need to make it as fast as possible, so waiting for, let's say, 5
seconds and then commencing execution of the native application is out
of the question. Any ideas? Thanks in advance!
Gordon Beaton - 18 Oct 2007 16:33 GMT
> And, before the first application is able to start and open sockets,
> the second one runs, tries to connect, fails and exits. I don't have
> any influence on that, I can only modify sources of the first
> application and the "master" one. Do you have some ideas on a nice
> way how master application can delay execution of the second
> program?

Your "master" application can start app1, then make several attempts
to connect to the socket. When that succeeds, it can close the
connection and start app2, which should then also succeed. This
assumes that app1 correctly deals with closed connections and multiple
clients.

/gordon

--
masterwally@gmail.com - 18 Oct 2007 16:56 GMT
> > And, before the first application is able to start and open sockets,
> > the second one runs, tries to connect, fails and exits. I don't have
[quoted text clipped - 12 lines]
>
> --

One thing I forgot to mention: the first app waits for only one
connection, and - after the socket closes - terminates itself. So your
solution would close my app1 after "master" tries succeeds...
Gordon Beaton - 18 Oct 2007 17:02 GMT
> One thing I forgot to mention: the first app waits for only one
> connection, and - after the socket closes - terminates itself. So
> your solution would close my app1 after "master" tries succeeds...

So change it. You said you could modify app1 and the master app.

You might also parse the output of an external tool like "lsof" or
"netstat" (or whatever's available for your platform) to see when the
socket is waiting for connections.

/gordon

--
Gordon Beaton - 18 Oct 2007 17:12 GMT
> One thing I forgot to mention: the first app waits for only one
> connection, and - after the socket closes - terminates itself. So
> your solution would close my app1 after "master" tries succeeds...

Another suggestion: master starts app1, then creates own ServerSocket
before starting app2. App2 connects to master's server, master then
connects to app1 (retrying if necessary) then acts as proxy between
the two applications.

/gordon

--
Laurent D.A.M. MENTEN - 18 Oct 2007 17:38 GMT
masterwally@gmail.com a écrit :
> Hello,
>
[quoted text clipped - 13 lines]
> seconds and then commencing execution of the native application is out
> of the question. Any ideas? Thanks in advance!

you may also wrap the second application and wait for your conditions to
be met before starting the real application...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.