Hi,
I'm creating a chat-application consisting of a client and a server. Both these programs use a specific thread to get data from the other.
The sending of the data takes place in the GUI-thread (event-thread?).
The creation of the ObjectStreams looks like this:
CLIENT-side
socket = new Socket(InetAddress.getByName(ipadr), 12345);
output = new ObjectOutputStream(socket.getOutputStream());
output.flush();
input = new ObjectInputStream(socket.getInputStream());
SERVER-side
Socket sock = serverSocket.accept();
output = new ObjectOutputStream(sock.getOutputStream());
output.flush();
input = new ObjectInputStream(sock.getInputStream())
Anyhow, (it seems to be pretty random) sometimes the first message sent on a stream doesn't reach the other application. It seems like sometimes the ObjectStreams are not initialized completely.
Are there some known problem I should avoid when creating the streams and using them in different threads (only one thread sending and one thread reading)?
The objects I send is of a class Message and it's subclasses containing only a String or a String-array. String-arrays are Serializable, right?
/ Mike
I'm creating a chat-application consisting of a client and a server. Both these programs use a specific thread to get data from the other.
The sending of the data takes place in the GUI-thread (event-thread?).
The creation of the ObjectStreams looks like this:
CLIENT-side
socket = new Socket(InetAddress.getByName(ipadr), 12345);
output = new ObjectOutputStream(socket.getOutputStream());
output.flush();
input = new ObjectInputStream(socket.getInputStream());
SERVER-side
Socket sock = serverSocket.accept();
output = new ObjectOutputStream(sock.getOutputStream());
output.flush();
input = new ObjectInputStream(sock.getInputStream())
Anyhow, (it seems to be pretty random) sometimes the first message sent on a stream doesn't reach the other application. It seems like sometimes the ObjectStreams are not initialized completely.
Are there some known problem I should avoid when creating the streams and using them in different threads (only one thread sending and one thread reading)?
The objects I send is of a class Message and it's subclasses containing only a String or a String-array. String-arrays are Serializable, right?
/ Mike