This repository was archived by the owner on Oct 4, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
server/src/main/java/com/server Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change 99import org .slf4j .LoggerFactory ;
1010
1111import java .io .*;
12+ import java .io .IOException ;
1213import java .net .ServerSocket ;
1314import java .net .Socket ;
1415import java .net .SocketException ;
@@ -27,16 +28,13 @@ public class Server {
2728
2829 public static void main (String [] args ) throws Exception {
2930 logger .info ("Selamat Datang Di PK-Chat. Pastikan Port 9001 Telah Terbuka!" );
30- ServerSocket listener = new ServerSocket (PORT );
3131
32- try {
32+ try ( ServerSocket listener = new ServerSocket ( PORT )) {
3333 while (true ) {
3434 new Handler (listener .accept ()).start ();
3535 }
3636 } catch (Exception e ) {
3737 e .printStackTrace ();
38- } finally {
39- listener .close ();
4038 }
4139 }
4240
@@ -58,7 +56,6 @@ public Handler(Socket socket) throws IOException {
5856 public void run () {
5957 logger .info ("Mencoba menghubungkan pengguna..." );
6058 try {
61- is = socket .getInputStream ();
6259 input = new ObjectInputStream (is );
6360 os = socket .getOutputStream ();
6461 output = new ObjectOutputStream (os );
You can’t perform that action at this time.
0 commit comments