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 / February 2006

Tip: Looking for answers? Try searching our database.

Need idea about client server connectivity (using ServerSocket and Socket)

Thread view: 
JPractitioner - 16 Feb 2006 08:00 GMT
Hi guys,

I have a class that listens to one port using ServerSocket. After
successfully receiving a packet, can i reply back to the client, in a
way that the client do not have to listen for incoming packets.

Thx in advance.
tom fredriksen - 16 Feb 2006 09:15 GMT
> Hi guys,
>
> I have a class that listens to one port using ServerSocket. After
> successfully receiving a packet, can i reply back to the client, in a
> way that the client do not have to listen for incoming packets.

If I understand your question correct, you are asking if the client can
get a reply without having to listen on a port of its own for the reply?
If that is the case then yes, in the jdk api page for the ServerSocket
class it states that it is a TCP socket, which means that the client
only has to do a read of the socket to get a reply.

Or are you perhaps asking of you can come back to the socket at a later
time to read the reply?

/tom
Chris Uppal - 16 Feb 2006 10:14 GMT
> I have a class that listens to one port using ServerSocket. After
> successfully receiving a packet, can i reply back to the client, in a
> way that the client do not have to listen for incoming packets.

Do you mean: without the client having to create, and listen on, a ServerSocket
of its own ?  If so then the answer is that when a ServerSocket recieves a
connection, that creates a two-way stream between the client and the server.
The server can send data back to the client on the newly created Socket.  The
client can read that data from the Socket connection that it opened to the
server.

If you mean something else, then I'm afraid you'll have to clarify what you
mean.

   -- chris
JPractitioner - 16 Feb 2006 21:15 GMT
Thanks a lot guys. Both answer are brilliant! I ve been enlightened.
Thanks again.

by the way, i was thinking to make a listener for the client as well.
but i'm glad that i asked here.


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.