import java.util.*;
import java.lang.*;
import java.io.*;
import java.net.*;
public class connect{
public static Socket socket;
public connect(Socket t)
{
t = socket;
}
public void send(String msg)
{
try
{
OutputStream os = socket.getOutputStream();
PrintStream out = new PrintStream(os);
out.print(msg);
out.flush();
}catch(Exception e){System.out.println("Error on send : " + e.getMessage());}
}
}
答案 0 :(得分:1)
您的socket
为空,
在你的构造函数
中public connect(Socket t)
{
t = socket;
}
您将传递的值t
设置为相等socket
,您需要以其他方式执行此操作
答案 1 :(得分:0)
连接方法中不应该是socket = t吗?