Til at sende med:
try
{
Socket socket=new Socket("
http://www.MinServer",1234);
ObjectOutputStream oos=new ObjectOutputStream(socket.getOutputStream());
Hashtable hash=new Hashtable();
hash.put("key","værdi");
oos.writeObject(hash);
oos.close();
socket.close();
}
catch(UnknownHostException e)
{
}
catch(IOException e)
{
}
Til at modtage:
try
{
Socket socket=new Socket("
http://www.MinServer",1234);
ObjectInputStream ois=new ObjectInputStream(socket.getInputStream());
Hashtable hash=(Hashtable)ois.readObject();
String vaerdi=(String)hash.get("key");
ois.close();
socket.close();
}
catch(UnknownHostException e)
{
}
catch(IOException e)
{
}
catch(ClassNotFoundException e)
{
}
p.s. Exception handling skal gøres pænere, men ovenstående skulle virke.