my dog learned polymorphism*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Socket connection" Watch "Socket connection" New topic

Socket connection

Anton Brass

Joined: Sep 08, 2010
Posts: 25

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

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?

Anton Brass

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

And will change it now to

Don't get me started about those stupid light bulbs.
subject: Socket connection
Similar Threads
How to Change the File Name for Each Uploaded Files to the Socket Server?
How to check server is up ?
Socket client unable to contact server on local host
SocketTimeoutException during serverSocket.accept()
not able to connect...