This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring 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: 152

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

I agree. Here's the link:
subject: Socket connection
jQuery in Action, 3rd edition