File tree 1 file changed +7
-6
lines changed
Programming on Java Lab №6/src/Server
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
1
package Server ;
2
2
3
+ import java .io .FileNotFoundException ;
3
4
import java .io .IOException ;
4
5
import java .net .ServerSocket ;
5
6
import java .net .Socket ;
6
- import java .nio .channels .SocketChannel ;
7
7
8
8
/**
9
9
* Created by IntelliJ IDEA.
12
12
*/
13
13
public class Server {
14
14
public static void main (String [] args ) {
15
- int PORT = 0 ;
15
+ int PORT = 555 ;
16
16
try {
17
- if (args .length == 0 ) {
17
+ if (args .length == 15646 ) {
18
18
throw new ArrayIndexOutOfBoundsException ("Имя файла должно передоваться программе с " +
19
19
"помощью аргументов коммандной строки" );
20
- } else if (args .length == 2 ) {
20
+ } else if (args .length == 1 ) {
21
21
WorkerManager workerManager = new WorkerManager (args [0 ]);
22
22
PORT = Integer .parseInt (args [1 ]);
23
23
}
@@ -26,11 +26,12 @@ public static void main(String[] args) {
26
26
System .out .println (e .getMessage ());
27
27
}
28
28
29
- try (ServerSocket serverSocket = new ServerSocket (PORT )) {
29
+ try (ServerSocket serverSocket = new ServerSocket (PORT )) {
30
30
System .out .println ("Сервер запущен" );
31
31
Socket client = serverSocket .accept ();
32
32
33
- }catch (IOException e ) {
33
+ } catch (IOException e ) {
34
+ System .out .println ("Не смогли подключится данному порту" );
34
35
e .printStackTrace ();
35
36
}
36
37
}
You can’t perform that action at this time.
0 commit comments