Hi all,
I'm having problems with sending objects through a socket.
The server thinks it has sent an object- calls the system.out() but the client has still not passed the objInputStream.readObject(); point.
Also the client will sometimes block at the outgoingSocket.getInputStream()) and i don't know why?
Client and server are on the same pc.
The code is fairly straightforward so i'm getting frustrated with this problem.
code snippets
client:
Server:
Thanks in advance
StevoIE
I'm having problems with sending objects through a socket.
The server thinks it has sent an object- calls the system.out() but the client has still not passed the objInputStream.readObject(); point.
Also the client will sometimes block at the outgoingSocket.getInputStream()) and i don't know why?
Client and server are on the same pc.
The code is fairly straightforward so i'm getting frustrated with this problem.
code snippets
client:
Code:
outgoingSocket = new Socket(ipaddress, portnumber);
outputStream=new PrintWriter(outgoingSocket.getOutputStream(), true);
outputStream.println(username);
objInputStream = new ObjectInputStream(outgoingSocket.getInputStream());
receivedVector = (Vector) objInputStream.readObject();
Server:
Code:
BufferedReader inStream = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
String username = inStream.readLine();
objectOutputStream = new ObjectOutputStream(clientSocket.getOutputStream());
objectOutputStream.writeObject(new Vector());
objectOutputStream.flush();
system.out("vector sent");
Thanks in advance
StevoIE