|
-
August 17th, 2011, 12:13 PM
#1
strange SocketChannel
Hi, All,
I am doing a TCP connection using SocketChannel.
I have a channel creation module, and a data collection module.
in the former module, user can input the parameters to setup the tcp connection.
in the latter one, a TCP listener is running to collect the data via tcp.
In the channel module, I use SocketChannel as a menber, when user input the parameters, SocketChannel is used to make a tcp connection. To keep the connection always on, there is a thread running in this module, if the connection disconnected, connect again, refresh the SocketChannel member after that.
In the TCP listener module, in its thread "run" method, get the current SocketChannel member from the above module, then read the data.
The problem is, if the tcp connection is reconnected, in the tcp listener module, the returned object is alway closed (isOpen is false), while it is open in the other module (tcp creation module) according to the system.out in it.
I don't know why the object refreshed in one thread is open locally, while accessed in another, it seems the value of it has been changed.
Anyone has any idea ?
Thanks,
Jerry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|