Re: how to wait for socket communications



I am thinking of using sockets, because this was suggested in the last post
to my question "Connecting Java to C++" in the Java Programming Forum at
forum.java.sun.com, the exact link being:
http://forum.java.sun.com/thread.jspa?threadID=5133663&tstart=0.

I am not sure why Alexander thought that sockets are not the right tool. I
think that the advantage using sockets might be that it is faster than
writing a file, since you can communicate a whole array.

Thanks for all your communications!


"Ali" wrote:

On May 14, 9:02 am, Ananya <Ana...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am trying to do socket communications between my C++ and my Java program.

I created a Java program for drawing curves and I connected it to Adobe's
C++ program for making a Photoshop plugin.

I am calling ShellExecuteEx for calling my Java program from C++, and it
brings up a separate window.

First I would like to communicate the Photoshop picture information into my
Java window. Originally I tried to to that with the lpParameters string in
ShellExecuteInfo, but it is too slow to build this string.

So now I am trying to communicate this with socket communication. I first
create a server in C++ before calling ShellExecuteEx, then I create a client
in Java in the main method, but how can I wait in C++ for this Java client to
be created before calling accept and sending the Photoshop picture
information?

I know I could just wait for a few seconds to make sure that my Java program
came up by calling:
if ( ei.hProcess != NULL )
{
WaitForSingleObject(ei.hProcess, 10*1000 );}

But I would rather not lose any time and just wait exactly until the Java
client is created.

And how can I wait in Java before receiving the picture information?

Finally, how can I wait in C++ for the Java program to close, at which point
the information of curves that were drawn in Java is sent to C++ (to be
received for the workpath in Photoshop)?

Thanks for your time looking at this.

Hmm, i though someone else will jump in to make this point clear. As
pointed by Alexander that using socket is not a good design approach.
His suggestion for mapped file is indeed flexible and commercial grade
solution BUT you can do that with simple file operation as i told in
previous thread. Why simple file I/O cant be your solution? and what
makes you think that sockets are good to use?

ali




.



Relevant Pages

  • Re: how to wait for socket communications
    ... What seems to be good about sockets is that you can communicate whole arrays ... I created a Java program for drawing curves and I connected it to Adobe's ... I am calling ShellExecuteEx for calling my Java program from C++, ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to wait for socket communications
    ... I created a Java program for drawing curves and I connected it to Adobe's ... C++ program for making a Photoshop plugin. ... I am calling ShellExecuteEx for calling my Java program from C++, ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to wait for socket communications
    ... I created a Java program for drawing curves and I connected it to Adobe's ... I am calling ShellExecuteEx for calling my Java program from C++, ... And how can I wait in Java before receiving the picture information? ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to wait for socket communications
    ... For the C++ side you can wait based on a network event on your socket. ... waiting for a UDP packet from your Java? ... I created a Java program for drawing curves and I connected it to Adobe's ... I am calling ShellExecuteEx for calling my Java program from C++, ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to wait for socket communications
    ... the JVM when the Java program gets closed, and ending up with memory leaks. ... Unfortunately, in connection with getting advised not to use sockets, my ... in this context as memory allocation technique, not file I/O. ...
    (microsoft.public.win32.programmer.networks)