Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keep a socket open

Status
Not open for further replies.

newbieKing

Programmer
Jan 29, 2003
19
CA
Hi, I'm writing some basic client server socket programs transferring multiple files from the server to the client. How do I keep the client's socket open so that multiple files go through that one socket?
Thanks in advance!
 
... then don't close the socket until you're done.

You may also want to call setKeepAlive() on the socket.

Tim
---------------------------
"Your morbid fear of losing,
destroys the light you're using." - Ozzy
 
Sounds like you should be using RMI.
RMI is a fairly thin wrapper around TCP sockets, but allows you the functionality to call methods on another server (Remote Method Invocation).

It means you don't have the headache of worrying about socket protocol etc.

Of course, if your client is in Java and your Server is in C/C++ this won't work, and you would need to look into Sockets, but if both are in Java, then RMI is defintely worth a look :


--------------------------------------------------
Free Database Connection Pooling Software
 
... unless you're a masochist and want to get to grips with CORBA :)

Tim
---------------------------
"Your morbid fear of losing,
destroys the light you're using." - Ozzy
 
LOL, unless you have to, I'd leave CORBA well alone.

I did some performance tests about 2 years ago using three client/server models : Pure Socket, RMI and CORBA.

In first place was Sockets [obviously], closely followed by RMI, with CORBA still stuck in third, trying to work out how to generate java classes from IDL at runtime :p

--------------------------------------------------
Free Database Connection Pooling Software
 
But it's the only way to do that when you have different systems with a certain degree of indepence and scalability.

Furthermore, there are real time implementations for CORBA, applied to very fast and key systems as submarines and missile control.

Cheers,

Dian
 
hello.. i haven't used java in many years, and i just came to this forum to post a question.. and i came across this post! i have been working with winsock in c++.. just curious.. what is the java equivalent?
 
java.net.ServerSocket and java.net.Socket

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
winsock in Java are the two TCP/IP classes java.net.Socket and java.net.ServerSocket .

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top