Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending object through socket problem

Status
Not open for further replies.

Stevoie

Programmer
Jun 7, 2001
68
IE
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:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top