Java 网络编程,该如何处理

Java 网络编程
    初学Java,练习一个网络编程的实例,有两个问题找不不出来原因(1.客户端发送的消息在服务器端无法显示;2.两个窗口均无法关闭,给窗体加的监听器貌似没起作用),不知如何解决,特来求教。我迷了,希望有前辈或者同行能帮我看看,万分感激。
代码如下:

//客户端程序代码
import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Client extends JFrame implements ActionListener {
Socket sock;           //定义套接字对象
JTextArea t1 = new JTextArea();
JTextField t2 = new JTextField(20);
JButton b1 = new JButton("发送");
JButton b2 = new JButton("连接服务器");
DataOutputStream out;      //定义数据输出流
DataInputStream in;        //定义数据输入流
public Client() {
JScrollPane jsp = new JScrollPane(t1);
t1.setEditable(false);
this.getContentPane().add(jsp,"Center");
JPanel p1 = new JPanel();
p1.add(t2);
p1.add(b1);
JPanel p2 = new JPanel();
p2.add(b2);
this.getContentPane().add(p2,"North");
this.getContentPane().add(p1,"South");
b1.addActionListener(this);
b2.addActionListener(this);
setTitle("客户端");
setSize(340,200);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent e){
/*try{
out.writeUTF("Bye");    //离开时告诉服务器
}
catch (Exception ee){}*/
dispose();                  //释放窗体资源
System.exit(0);             //退出窗体   
}
});
}
public void actionPerformed(ActionEvent e){
if (e.getSource() == b1){
if (!t2.getText().equals("")){
try{
out.writeUTF(t2.getText());     //向服务器发送消息
t1.append("客户说:"+t2.getText()+"\n");
}catch(Exception ee){}
t2.setText("");
}
}
else {
try {
sock = new Socket("127.0.0.2",3000);  //建立与服务器连接的套接字
OutputStream os = sock.getOutputStream(); //根据套接字获得输出流
//使用输出流建立数据输出流(更高级的流)
out = new DataOutputStream(os);
InputStream is = sock.getInputStream(); //根据套接字获得输入流
//根据输入流建立数据输入流(更高级的流)
in = new DataInputStream(is);
Communnion th = new Communnion(this);   //建立线程
th.start();                             //启动线程
}
catch(IOException ee){
JOptionPane.showMessageDialog(null,"连接服务器失败!");
return;
}
}
}
public static void main(String[] args) {
Client mainFrame = new Client();
}
}
class Communnion extends Thread {
Client fp;
Communnion(Client fp){
this.fp = fp;
}
public void run(){
String msg = null;
while(true){
try {
msg = fp.in.readUTF();
 //如果服务器端退出
if (msg.equals("Bye")){
fp.t1.append("服务器已经停止\n");
break;
}
fp.t1.append("服务器说:"+msg+"\n");
}
catch (Exception ee){