-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macket messenger #130
base: master
Are you sure you want to change the base?
Macket messenger #130
Conversation
import java.util.LinkedList; | ||
|
||
public class MyServer { | ||
private static final int BUFSIZE = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не жмитесь, сделайте буфер 2048 чтобы не иметь проблем с размером сообщения
if (args.length != 1) { | ||
throw new IllegalArgumentException("Parameter: <Port>"); | ||
} | ||
LinkedList<Integer> list = new LinkedList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
название ни о чем
Socket clntSock = serverSocket.accept(); | ||
outs.addLast(clntSock.getOutputStream()); | ||
|
||
Thread inThread = new Thread() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эти треды стоит где-то сохранять, чтобы потом можно было ими управлять.
Например список
|
||
InputStream in = clntSock.getInputStream(); | ||
|
||
while ((recvMsgSize = in.read(recieveBuf)) != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У вас работа с клиентом уже вынесена в поток. Вы же на каждое чтение заводите еще один новый поток на запись.
Либо оставьте запись в основном потоке либо заведите отдельный, но 1 и передавайте ткда данные через очередь
No description provided.