aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes socket callback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket callback" Watch "socket callback" New topic
Author

socket callback

sen sen
Greenhorn

Joined: Aug 24, 2007
Posts: 1
Hi, Ranchers;
I am writing a java client socket.

The server socket is written in c++ and is running out there, it keeps listening to a socket on a specific port, once it receives something from the listened socket, it does some calculations and returns the results to the same listened socket(or possibly another one).

Now come back to my java client socket, it sends a string to the socket which it is connected to, and then it may need to do something else, once there is something returned from the server in the socket, the client should be informed and pick up the corresponding result for the string it just sent.
For this problem, I need an asynchronous callback mechanism in my client side, all I have is the server's IP and the port number the socket will be connected. I've read a couple of posts and articles in the web, but seems did not resolve my problem, can any one help out? any help is greatly appreciated.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You can do the asynchronous bit in your code:

If you want the worker object to do a callback on some object on its own thread, maybe pass the callback object in the constructor and forget about it:

Do those look interesting?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: socket callback
 
Similar Threads
Rewriting data into a socket fails...?
Can Someone tell me what I am doing wrong??
Socket push..
Client Failed to connect, how do I attempt a reconnect?
java.net Socket port number question