F
farseer
I have a server that listens for connections. A selector is opened,
configured for non-blocking and the serverchannel is used to register
OP_ACCEPT on this selector. in the main loop, once i accept a
connection, i immediately register OP_READ on the selector.
So far so good...A connection request is made by a client, i accept, i
register to read; when the client sends data, i read the data and send
back an ACK. All good!
Now, i created a client which simply connects to the server, sends a
message and recieves back an acknowledgement from the server. about
100 to 500 client threads are created for testing. They all work
flawlessly, almost. the server accepts each connection, process the
data each thread sends and then when it's done with all connections,
blocks on select() it appears.
THE PROBLEM IS: when i now kill the client process (the one with 100
to 500 threads), the server immediately wakes up and tries to process a
READ_OP event. I currently handle this by closing/canceling the key
and channel if an IOException is detected in the method that reads, but
i am wondering why does the Server wake up when clients abruptly
disconnects?
I also noticed the converse happens..if the server is killed, the
client tries to process a OP_READ event.
Anyone with some thoughts?
configured for non-blocking and the serverchannel is used to register
OP_ACCEPT on this selector. in the main loop, once i accept a
connection, i immediately register OP_READ on the selector.
So far so good...A connection request is made by a client, i accept, i
register to read; when the client sends data, i read the data and send
back an ACK. All good!
Now, i created a client which simply connects to the server, sends a
message and recieves back an acknowledgement from the server. about
100 to 500 client threads are created for testing. They all work
flawlessly, almost. the server accepts each connection, process the
data each thread sends and then when it's done with all connections,
blocks on select() it appears.
THE PROBLEM IS: when i now kill the client process (the one with 100
to 500 threads), the server immediately wakes up and tries to process a
READ_OP event. I currently handle this by closing/canceling the key
and channel if an IOException is detected in the method that reads, but
i am wondering why does the Server wake up when clients abruptly
disconnects?
I also noticed the converse happens..if the server is killed, the
client tries to process a OP_READ event.
Anyone with some thoughts?