Hi.
I'm writing a client-server program and I need to pass objects between them. Since there are several different object to send, I have created a class named Message and decided that every object that is sent will be packed inside a Message.
For some reason it doesn't work...
Here is a part from my code, where the client tries to send a message to the server:
In the client side:
User user = new user(123, "David", "USA");
Sockect socket = new Socket(ServerName,ServerPort);
Message message = new Message(user ,"LOGIN");
ObjectOutputStream objectoutputstream = new ObjectOutputStream(socket.getOutputStream());
objectoutputstream.writeObject(message);
ObjectInputStream objectinputstream = new ObjectInputStream(socket.getInputStream());
Thread thread = new Thread(this);
thread.start();
In the server side:
Message recievedMessage;
while(thread != null)
{
try
{
recievedMessage= (Message)inputstream.readObject();
/*******RFC Checking**************/
if(recievedMessage.getType().equals("LOGIN"))
{
//do login...
}
}
catch(Exception ex)
{
}
...
...
}
But it doesn't work... It's my first time using ObjectInputStream/ObjectInputStreamand i guess I'm doing some basic mistakes...
What is the problem?
Thanks!