我正在努力查看这里出了什么问题(课程的一部分):
public class Network implements Runnable {
private static Network cachedInstance;
private static boolean connected;
//private Socket clientSocket;
private SSLSocket clientSocket;
private PrintWriter out;
private BufferedReader in;
private Map<String, SyncObject> waitForServer;
private Network(final String hostname, final int port) {
try {
Socket baseSocket = new Socket();
baseSocket.connect(new InetSocketAddress(hostname, port), Config.TIMEOUT);
clientSocket = (SSLSocket)SSLSocketFactory.createSocket(baseSocket, hostname, port, true);
clientSocket.startHandshake();
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
connected = true;
} catch (IOException ex) {
connected = false;
}
waitForServer = new HashMap<>();
}
我收到一个错误:
C:\Users\Frank\Dropbox\NetbeansProjects\TradingCardGame\src\network\Network.java:47: error: non-static method createSocket(Socket,String,int,boolean) cannot be referenced from a static context
clientSocket = (SSLSocket)SSLSocketFactory.createSocket(baseSocket, hostname, port, true);
我什至如何处于静态环境中?
问候。