Overclock.net banner

1 - 2 of 2 Posts

·
Premium Member
Joined
·
5,282 Posts
Discussion Starter #1
I'm having some trouble with the networking I'm doing between a server and a mobile client. During testing we often have to kill and restart the server while the client is running. If this happens, no more data can be sent between them until the client restarts. Here is what happens

Server starts up

Client starts up

Client connects to server

...they do stuff...

Server shuts down

Server restarts

Client attempts to send data - sees that the connection is dead (broken pipe exception)

Client reestablishes connection (successfully - no errors)

Client attempts to send data - java throws a bad socket exception

Here is a sample from the client's log

Code:

Code:
V/Message Service( 3387): Attempting to connect to (<SERVER HOSTNAME>:4312) 
V/Message Service( 3387): Connection successful
V/Message Service( 3387): Opening output stream
V/Message Service( 3387): Opening input stream
V/Message Service( 3387): Streams established
V/Message Sending Thread( 3387): Sending message size [152192] bytes...
V/Message Sending Thread( 3387): Message sent
V/Message Listening thread( 3387): Read [4] / [4]
I/System.out( 3387): Receiving message of [395] bytes
V/Message Listening thread( 3387): Read [395] / [395]
V/Message Service( 3387): Recieved Message

// stuff happens back and forth 
// server quits and restarts in here

V/Picture Manager( 3317): Sending fragment
V/Message Sending Thread( 3317): Sending message size [152192] bytes...
E/Message Sending Thread( 3317): Error sending message: Broken pipe
V/Message Service( 3317): Nuking connection

// the above is expected, on the nuking step the client closes all streams and the socket

V/Message Service( 3317): Attempting to connect to (<SERVER HOSTNAME>:4312) 
V/Message Service( 3317): Connection successful
V/Message Service( 3317): Opening output stream
V/Message Service( 3317): Opening input stream
V/Message Service( 3317): Streams established
V/Message Sending Thread( 3317): Sending message size [152192] bytes...
E/Message Sending Thread( 3317): Error sending message: Bad socket
E/Message Service( 3317): Unable to connect
V/Message Service( 3317): Nuking connection
V/Picture Manager( 3317): Connection failed

// this repeats until the client is restart
From this point on, any time I try to send data I get the bad socket error. The client can disconnect from and connect to the server with no problem, and the server correctly detects that the client is successfully disconnecting from and connecting to the server, and I can open input/output streams between them with no problem, but I can't send any data back and forth.

Does anybody know why this is happening or how to solve it?
 

·
Premium Member
Joined
·
11,272 Posts
Can't say without seeing the code, but if I had to guess I'd say you're forgetting to close/reuse/whatever some socket or handler or something somewhere.
 
1 - 2 of 2 Posts
Top