Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can Socket() class listen for messages from a remote server

843790May 5 2009 — edited May 7 2009
I am writing a small Java app which needs to connect to several remote servers.
At various intervals each of these servers will send messages to one of their ports, regardless of whether anything is listening or not.

Using the Socket() Class I have been able to write a program which connects to one of the server ports, then requests and receives some of the data.

But I really need this client program to act as a listener, in the way that ther ServerSocket() class does.

A crude solution I came up with involved an infinite loop, Although it sort of worked, it also caused the CPU to max out.

Does anyone know if there is a method which allows the Socket() class to listen for messages from a remote server?

Edited by: A-Marquis on May 5, 2009 3:15 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2009
Added on May 5 2009
11 comments
280 views