Skip to content
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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Macket messenger #130

wants to merge 20 commits into from

Conversation

Macket
Copy link

@Macket Macket commented Apr 21, 2017

No description provided.

import java.util.LinkedList;

public class MyServer {
private static final int BUFSIZE = 100;
Copy link
Owner

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<>();
Copy link
Owner

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() {
Copy link
Owner

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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У вас работа с клиентом уже вынесена в поток. Вы же на каждое чтение заводите еще один новый поток на запись.

Либо оставьте запись в основном потоке либо заведите отдельный, но 1 и передавайте ткда данные через очередь

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants