Re: a problem with Socket
From: alessandro (halex2000_at_virgilio.it)
Date: 08/13/04
- Next message: David Segall: "Re: Does IBM has a JDK implementation for windows?"
- Previous message: VisionSet: "Re: throw in a finally"
- In reply to: Gordon Beaton: "Re: a problem with Socket"
- Next in thread: Chris Uppal: "Re: a problem with Socket"
- Reply: Chris Uppal: "Re: a problem with Socket"
- Reply: NetShiva: "Re: a problem with Socket"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 13 Aug 2004 13:58:25 GMT
Ok, now the problem with the connection is solved: when the server was
listening and I closed the connection, I didn't call ServerSocket.close(),
so the next time the system wouln't let me create the same ServerSocket.
> Use a java.nio.Selector to handle multiple connections from a single
> thread.
I don't know what JVM version is installed on the target machine. It could
be not the 1.4. Other than that, is not this the very problem.
> On the other hand, if there will only be a single connection, there is
> no reason to not let your process block while waiting for input from
> the peer.
There is a GUI. The user should be able to interact with it.
>If you use ready() or available() in a loop that just reads
> from a single Reader or InputStream, you are simply wasting CPU in
> order to avoid an imagined problem.
This would not be a problem. The read() method would be called from a timer
10 times per second or so.
The problem is that (following the documentation), available() always
returns 0 on some systems, and should not be used in these manners. Then I
tried ready(), but returns false. I would like not to use a separate thread
for the network class, since that would mean adding a lot of extra code.
This app will be used just one time (university project) from my
professor...
Thank you for the help.
Alessandro
- Next message: David Segall: "Re: Does IBM has a JDK implementation for windows?"
- Previous message: VisionSet: "Re: throw in a finally"
- In reply to: Gordon Beaton: "Re: a problem with Socket"
- Next in thread: Chris Uppal: "Re: a problem with Socket"
- Reply: Chris Uppal: "Re: a problem with Socket"
- Reply: NetShiva: "Re: a problem with Socket"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|