Re: a problem with Socket

From: alessandro (halex2000_at_virgilio.it)
Date: 08/13/04


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



Relevant Pages

  • Re: Cannot connect to SQL Express on 2003 Machine from XP machine
    ... listening on UDP 1434 using netstat -abn, ... And i double checked the connection string, and i did have it the right ... But I have another 2000 server that I can connect to fine, ... I am trying to connect from an XP SP2 machine remotely to a SQL Express ...
    (microsoft.public.sqlserver.connect)
  • RE: reusing TcpClient object
    ... try to create a separate thread for connection which is using a ... > client and I need to send one message per event. ... > the listening application whenever I need to send something. ... the connection process blocks the thread for a ...
    (microsoft.public.dotnet.framework)
  • Re: Detect Disconnect in WinSock 2.0
    ... You can poll socket by selectfunction in separate thread. ... the server I can't get any intimation regarding the disconnection. ... In other case if after successful connection I try to send/receive data ...
    (microsoft.public.win32.programmer.networks)
  • Re: connect() - tcpdump output question
    ... Connection rejected? ... port on the server. ... server to check if there is a indeed something listening on the right port. ...
    (comp.os.linux.networking)
  • Re: accept 1000 or more incoming conection
    ... The listen function places a socket a state where it is listening for ... SOCKET s, ... Now i have developed a client that Makes 500 connection to a server at ...
    (comp.programming.threads)