0
我試圖通過調用類的默認構造函數來啓動一個套接字服務器,但是服務器沒有啓動無法啓動socket服務器的Java
下面是我的服務器套接字類:
import java.io.*;
import java.net.*;
public class TransactionServer
{
public void TransactionServer() throws IOException {
System.out.println("Inside Create Server");
Socket echoSocket;
InputStream sin = null;
OutputStream sout = null;
ObjectInputStream sinO=null;
ObjectOutputStream soutO=null;
try {
ServerSocket s = new ServerSocket(2000);
System.out.println("Server Ruinning");
echoSocket = s.accept();
System.out.println("Connection from: " + echoSocket.getInetAddress());
sinO = new ObjectInputStream(echoSocket.getInputStream());
soutO = new ObjectOutputStream(echoSocket.getOutputStream());
String temp = (String) sinO.readObject();
System.out.println("" + temp);
} catch (Exception e) {
System.err.println(e);
return;
}
}
}
下面是我的調用此類的對象:
public class TabbedPane extends JFrame {
public TabbedPane() {
TransactionServer newServer=new TransactionServer();
}
}
但是服務器沒有啓動。
好的。他認爲構造函數實際上是一個無效的方法。 +1 – 2014-11-05 05:11:46