Skip to content

Commit 8fe5a41

Browse files
authored
earth opened her mouth, and swallowed up the flood
And the earth helped the woman, and the earth opened her mouth, and swallowed up the flood which the dragon cast out of his mouth. (Revelation 12:16)
1 parent d02cbc9 commit 8fe5a41

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
//And the earth helped the woman, and the earth opened her mouth, and swallowed up the flood which the dragon cast out of his mouth. (Revelation 12:16)
3+
4+
package com.javarush.task.task40.task4005;
5+
6+
7+
import java.io.Closeable;
8+
import java.io.IOException;
9+
import java.io.ObjectInputStream;
10+
import java.io.ObjectOutputStream;
11+
import java.net.Socket;
12+
13+
/*
14+
Сокетный сервер и клиент
15+
*/
16+
17+
public class Connection implements Closeable {
18+
private final Socket socket;
19+
private final ObjectInputStream in;
20+
private final ObjectOutputStream out;
21+
22+
public Connection(Socket socket) throws Exception {
23+
this.socket = socket;
24+
25+
this.out = new ObjectOutputStream(socket.getOutputStream());
26+
this.in = new ObjectInputStream(socket.getInputStream());
27+
}
28+
29+
public void send(String message) throws Exception {
30+
out.writeObject(message);
31+
}
32+
33+
public String receive() throws Exception {
34+
return (String) in.readObject();
35+
}
36+
37+
@Override
38+
public void close() throws IOException {
39+
in.close();
40+
out.close();
41+
socket.close();
42+
}
43+
}
44+
45+
/*
46+
Сокетный сервер и клиент
47+
48+
Есть сервер, он принимает входящие сообщения от клиентов и отвечает им echo.
49+
50+
Есть клиенты, они считывают сообщения с клавиатуры и отправляют их серверу.
51+
52+
Программа запускается, но не работает.
53+
54+
Разберись в чем проблема, внеси минимальные изменения в код, чтобы все заработало.
55+
56+
57+
58+
59+
60+
Требования:
61+
62+
1. Класс Client не изменяй.
63+
64+
2. Класс Server не изменяй.
65+
66+
3. Внеси необходимые изменения в класс Connection.
67+
68+
4. Поля в классе Connection не изменяй.
69+
*/

0 commit comments

Comments
 (0)