File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Socket connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Socket connection" Watch "Socket connection" New topic
Author

Socket connection

Anton Brass
Greenhorn

Joined: Sep 08, 2010
Posts: 25
Hey,

I implemented a socket based connection for the UrlyBird project.

Is it true that the connection is only useable once?

I tried to build up the connection inside the constructor of my Client class:


For the first action, everything works fine. If I try to send another message I get a "Access time out" SocketException. My Server code is following:

Anton Brass
Greenhorn

Joined: Sep 08, 2010
Posts: 25
I forgot to wrote that if I initialize and close the connection for every request, it works totally fine.
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 140

It looks like your SocketRequest thread dies.
Did you put a



inside you run() method to prevent it from ending?


SCJP, SCWCD, SCJD
Anton Brass
Greenhorn

Joined: Sep 08, 2010
Posts: 25
Ah, could be the problem. I had it this way:



And will change it now to

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Socket connection