2023-12-20 17:35:53 +01:00

46 lines
1.1 KiB
Java

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package ChatProgramm.model;
import ChatProgramm.util.OhmLogger;
import ChatProgramm.view.ChatView;
import java.io.IOException;
import java.net.ServerSocket;
import java.util.logging.Logger;
/**
* Builder Class
* @author le
*/
public class Server extends Transmitter
{
private static Logger lg = OhmLogger.getLogger();
private static final int PORT = 35000; //lt. iana port > 2¹⁵
public Server(ChatView view, ChatModel model) throws IOException {
super(view, model);
connect();
initIO();
}
public void connect() throws IOException
{
try
{
ServerSocket sSocket = new ServerSocket(PORT);
sSocket.setSoTimeout(timeout);
lg.info("Server: warte auf Verbindung");
socket = sSocket.accept();
lg.info("Server: Verbindung akzeptiert");
}
catch ( java.io.InterruptedIOException e )
{
lg.warning("Timeout"+"("+timeout/1000+"s)");
}
}
}