现在用Java写的一个服务器端的程序,让delphi调用,现在能连接上,也能读取信息,但是当delphi发送给Java时,Socket 自动断开,请高手指点?
package com.dsc.mandiq.service;
import java.net.*;
import java.io.*;
import java.util.*;public class MandiqServer{
  
  //定义网络相关变量
  static Vector clients=new Vector(10);   //用向量数组存储连接客户变量
  static ServerSocket server=null;        //建立服务器socket
  static int active_connects=0;           //用来存储目前连接的客户数
  static Socket socket=null;               //用来存储一个套接字连接
   public static void main(String[] args)
  {
    //实例化一个MandiqServer类
    MandiqServer MandiqServer1=new MandiqServer(); 
System.out.println("服务端 启动.....");
try
   {
    //使用端口1234初始化服务器套接字
    server=new ServerSocket(1234);
    //server.setSoTimeout(3000);
}
catch(IOException e)
   {
    System.out.println("Error:"+e);
}
while(true)
   {
   //当客户数小于10个时开始连接
    if(clients.size()<10)
   {
    try
   {
     //用来存储连接上的客户socket
    socket=server.accept();
    while(true){
     if(socket!=null)
     {
    System.out.println(socket+"连接"); 
    break;
        }
      }
   }
catch(IOException e)
   {
    System.out.println("Error:"+e);
   }
     //定义并实例化一个Client线程类,一个就对应一个客户连接
        Client c=new Client(socket);
            //加入clients数组中
        clients.addElement(c);
    System.out.println("调用checkName方法验证客户端的合法性");
 //定义connum来存储活动连接数
    int connum=++MandiqServer1.active_connects; 
    //在状态栏里显示连接数
    String constr="目前有"+connum+"客户相连";  
    System.out.println(constr);
    //将连接客户的socket信息存储进listdata数组
    Client listdata=(Client)clients.elementAt(clients.size()-1); 
    //将客户socket信息写入list框
    System.out.println(listdata.ip+"连接");
    //启动线程
    c.start();
    //用notifyRoom方法来监视聊天室连接变化
    //notifyRoom();                                 
//不断改变clients数组并刷新客户端信息
sendClients(c,"你好! "+c.name+"!欢迎你进入!",c.name+" 聊天系统 !");
}
else//如果clients数组超过了10个
   {
try{Thread.sleep(200);}
catch(InterruptedException e)   {
                            System.out.println("Error:"+e);
}
}
}//end of while
  }// end of main method  public MandiqServer() //MandiqServer类的构造器用来初始化一些UI信息
  {
  }                  public static synchronized void sendClients(String msg)   //实现sendClients方法专用来向每个连接的客户端发送信息
  {
     for(int i=0;i<clients.size();i++)
{
     Client c=(Client)clients.elementAt(i);
 c.send(msg);
 System.out.println("向每个连接的客户端发送信息:"+msg);
 }
  }
  
  public static synchronized void sendClients(Client s,String Truesay,String Falsesay)  
  {
   String Tsay=Truesay;
   String Fsay=Falsesay;
  
     for(int i=0;i<clients.size();i++)
{
     Client c=(Client)clients.elementAt(i);
if (c.equals(s))
c.send("所有信息:"+" "+Tsay);
else
c.send("所有信息:"+" "+Fsay);
 }
  }
 public static void startService(){
// 实例化一个MandiqServer类
    MandiqServer MandiqServer1=new MandiqServer(); 
System.out.println("服务端 启动.....");
try
   {
    //使用端口1234初始化服务器套接字
    server=new ServerSocket(1234);
    //server.setSoTimeout(3000);
}
catch(IOException e)
   {
    System.out.println("Error:"+e);
}
while(true)
   {
   //当客户数小于10个时开始连接
    if(clients.size()<10)
   {
    try
   {
     //用来存储连接上的客户socket
    socket=server.accept();
    while(true){
     if(socket!=null)
     {
    System.out.println(socket+"连接"); 
    break;
        }
      }
   }
catch(IOException e)
   {
    System.out.println("Error:"+e);
   }
     //定义并实例化一个Client线程类,一个就对应一个客户连接
        Client c=new Client(socket);
            //加入clients数组中
        clients.addElement(c);     System.out.println("调用checkName方法验证客户端的合法性");
 //定义connum来存储活动连接数
    int connum=++MandiqServer1.active_connects; 
    //在状态栏里显示连接数
    String constr="目前有"+connum+"客户相连";  
    System.out.println(constr);
    //将连接客户的socket信息存储进listdata数组
    Client listdata=(Client)clients.elementAt(clients.size()-1); 
    //将客户socket信息写入list框
    System.out.println(listdata.ip+"连接");
    //启动线程
    c.start();                 
//不断改变clients数组并刷新客户端信息
sendClients(c,"你好! "+c.name+"!欢迎你进入!",c.name+" 聊天系统 !");
}
else//如果clients数组超过了10个
   {
try{Thread.sleep(200);}
catch(InterruptedException e)   {
                            System.out.println("Error:"+e);
}
}
}//end of while
 }
}
以下是我的delphi调用的方法:  ClientSocket1.Port:=1234;
  ClientSocket1.Address:='192.168.1.119';
  clientsocket1.Open;
  ClientSocket1.Socket.SendText('PEOPLE:sfq:192.168.1.102'+#10);