/*
* To change this
template, choose Tools | Templates
* and open the
template in the editor.
*/
package clientsocket;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.ClassNotFoundException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
public class Main {
/**
* @param args the
command line arguments
*/
public static void
main(String[] args) {
try
{
InetAddress
host = InetAddress.getLocalHost();
Socket socket
= new Socket(host.getHostName(),7777);
ObjectOutputStream oos = new
ObjectOutputStream(socket.getOutputStream());
oos.writeObject("Hellow there");
ObjectInputStream ois =new ObjectInputStream(socket.getInputStream());
String
strMessage = (String)ois.readObject();
System.out.println("Message:" + strMessage);
oos.close();
ois.close();
}
catch(UnknownHostException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
}