Results 1 to 1 of 1
- 04-05-2009, 03:59 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 1
- Rep Power
- 0
java.io.EOFException: send vector from client to server through socket
I want to send a vector<string> from client to server through socket.
It gave me the following error:
"java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFull y(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.rea dShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at testing.testing1.run(testing1.java:337)"
when I tried the following code:
Client side:
Socket socket = null;
DataOutputStream dout;
ObjectOutputStream oos;
try
{
for (int i=0; i<list.size(); i++)
{
socket = new Socket(list.elementAt(i),PORT);
PrintWriter outStart = new PrintWriter(socket.getOutputStream(), true);
outStart.println(START);
outStart.flush();
//transmit vector<string>
dout = new DataOutputStream (socket.getOutputStream());
oos = new ObjectOutputStream (dout);
oos.writeObject(list);
oos.flush();
PrintWriter outInitialize = new PrintWriter(socket.getOutputStream(), true);
outInitialize.println(INITIALIZED);
outInitialize.flush();
socket.close();
}
}
catch (IOException e)
{
e.printStackTrace();
}
Server side:
Socket socket;
ServerSocket serverSocket;
DataInputStream din;
ObjectInputStream ois;
try
{
serverSocket = new ServerSocket(PORT);
socket = serverSocket.accept();
din = new DataInputStream(socket.getInputStream());
ois = new ObjectInputStream (din);
@SuppressWarnings("unchecked")
Vector<String> list = (Vector<String>)ois.readObject();
socket.close();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
Could any give a help?
Similar Threads
-
Server socket - send image to client
By Hinty in forum NetworkingReplies: 2Last Post: 03-14-2009, 07:39 AM -
Client Server socket problem - help needed
By kellaw in forum Threads and SynchronizationReplies: 6Last Post: 10-03-2008, 06:49 PM -
send/read int in a client/server app
By dim_ath in forum New To JavaReplies: 2Last Post: 01-03-2008, 01:03 PM -
how to send .jar files client to server
By gobinathm in forum NetworkingReplies: 1Last Post: 12-25-2007, 04:05 AM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks