diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build.xml b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build.xml
new file mode 100644
index 0000000..e68448c
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project ChatClientJ130_lesson4_group1.
+
+
+
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/built-jar.properties b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/built-jar.properties
new file mode 100644
index 0000000..b19c99c
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/built-jar.properties
@@ -0,0 +1,4 @@
+#Wed, 25 Jan 2023 21:23:33 +0300
+
+
+C\:\\Users\\denis.LAPTOP-4LI8UQ4O\\OneDrive\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\NetBeansProjects\\ChatClientJ130_lesson4_group1=
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/.netbeans_automatic_build b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/.netbeans_update_resources b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ChatServer.class b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ChatServer.class
new file mode 100644
index 0000000..039a0c5
Binary files /dev/null and b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ChatServer.class differ
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ClientFrame.class b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ClientFrame.class
new file mode 100644
index 0000000..abca0df
Binary files /dev/null and b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ClientFrame.class differ
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ClientProperties.class b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ClientProperties.class
new file mode 100644
index 0000000..e75928b
Binary files /dev/null and b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/ClientProperties.class differ
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/MainClass.class b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/MainClass.class
new file mode 100644
index 0000000..f53d0c1
Binary files /dev/null and b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/build/classes/chatclientj130_lesson4_group1/MainClass.class differ
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/client.property b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/client.property
new file mode 100644
index 0000000..f8e59cd
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/client.property
@@ -0,0 +1,2 @@
+#Wed Jan 25 16:16:48 MSK 2023
+username=Denis
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/ChatClientJ130_lesson4_group1.jar b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/ChatClientJ130_lesson4_group1.jar
new file mode 100644
index 0000000..08ae24c
Binary files /dev/null and b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/ChatClientJ130_lesson4_group1.jar differ
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/README.TXT b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/README.TXT
new file mode 100644
index 0000000..c31b6f0
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/README.TXT
@@ -0,0 +1,32 @@
+========================
+BUILD OUTPUT DESCRIPTION
+========================
+
+When you build an Java application project that has a main class, the IDE
+automatically copies all of the JAR
+files on the projects classpath to your projects dist/lib folder. The IDE
+also adds each of the JAR files to the Class-Path element in the application
+JAR files manifest file (MANIFEST.MF).
+
+To run the project from the command line, go to the dist folder and
+type the following:
+
+java -jar "ChatClientJ130_lesson4_group1.jar"
+
+To distribute this project, zip up the dist folder (including the lib folder)
+and distribute the ZIP file.
+
+Notes:
+
+* If two JAR files on the project classpath have the same name, only the first
+JAR file is copied to the lib folder.
+* Only JAR files are copied to the lib folder.
+If the classpath contains other types of files or folders, these files (folders)
+are not copied.
+* If a library on the projects classpath also has a Class-Path element
+specified in the manifest,the content of the Class-Path element has to be on
+the projects runtime path.
+* To set a main class in a standard Java project, right-click the project node
+in the Projects window and choose Properties. Then click Run and enter the
+class name in the Main Class field. Alternatively, you can manually type the
+class name in the manifest Main-Class element.
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/client.property b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/client.property
new file mode 100644
index 0000000..5ec320b
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/dist/client.property
@@ -0,0 +1,2 @@
+#Wed Jan 25 21:23:49 MSK 2023
+username=Denis
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/manifest.mf b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/build-impl.xml b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/build-impl.xml
new file mode 100644
index 0000000..a981173
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/genfiles.properties b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/genfiles.properties
new file mode 100644
index 0000000..0bb2c8e
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=016dcbec
+build.xml.script.CRC32=9c6d8abd
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=016dcbec
+nbproject/build-impl.xml.script.CRC32=5111007c
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/private/private.properties b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/private/private.xml b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/private/private.xml
new file mode 100644
index 0000000..1613d57
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/private/private.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ChatServer.java
+ file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/MainClass.java
+ file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientFrame.java
+ file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientProperties.java
+
+
+
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/project.properties b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/project.properties
new file mode 100644
index 0000000..fa7e4f4
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/ChatClientJ130_lesson4_group1.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=chatclientj130_lesson4_group1.MainClass
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/project.xml b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/project.xml
new file mode 100644
index 0000000..5b73c35
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ ChatClientJ130_lesson4_group1
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ChatServer.java b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ChatServer.java
new file mode 100644
index 0000000..52fa89a
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ChatServer.java
@@ -0,0 +1,125 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group1;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.Socket;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JLabel;
+import javax.swing.JTextArea;
+
+/**
+ *
+ * @author Denis
+ */
+public class ChatServer implements Runnable{
+
+ private static ChatServer chatServer;
+ private boolean isExit = false;
+ private JLabel topLabel;
+ private JTextArea chatingText;
+
+ private ChatServer(JLabel topLabel, JTextArea chatingText){
+ this.chatingText = chatingText;
+ this.topLabel = topLabel;
+ }
+
+ public static ChatServer getState(JLabel topLabel, JTextArea chatingText){
+ Thread thread = null;
+ if(chatServer==null) {
+ chatServer = new ChatServer(topLabel, chatingText);
+ thread = new Thread(chatServer);
+ thread.start();
+ }
+ if(thread!=null && thread.getState().toString().equals("TERMINATED")){
+ thread = new Thread(chatServer);
+ thread.start();
+ }
+ return chatServer;
+ }
+
+ @Override
+ public void run() {
+ while(!isExit){
+ updateChat();
+ try {Thread.sleep(1000);} catch (InterruptedException ex) {}
+ }
+ }
+
+ private void updateChat(){
+ try (Socket socket = new Socket(ClientProperties.getState().getServerHost(), ClientProperties.getState().getServerPort());
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();){
+ //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));){
+ String labelText = topLabel.getText();
+ if(socket.isConnected()) topLabel.setText("" + labelText + "");
+ //writer.write("get messages\n");
+ os.write("get messages".getBytes());
+ socket.shutdownOutput();
+ //writer.flush();
+ byte[] buffer = new byte[1024];
+ int length;
+ StringBuilder sb = new StringBuilder();
+ while((length=is.read(buffer))>-1){
+ sb.append(new String(buffer, 0, length));
+ }
+ String answer = sb.toString();
+ chatingText.setText(answer);
+ } catch (IOException ex) {
+ String labelText = topLabel.getText();
+ topLabel.setText("" + labelText + "");
+ Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public void sendMessage(String message){
+ String username = ClientProperties.getState().getUsername();
+ message = "post" + username + " >> " + getCurrentTime() + " >> " + message;
+ try (Socket socket = new Socket(ClientProperties.getState().getServerHost(), ClientProperties.getState().getServerPort());
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();){
+ //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));){
+ String labelText = topLabel.getText();
+ if(socket.isConnected()) topLabel.setText("" + labelText + "");
+ System.out.println(message);
+ os.write(message.getBytes());
+ //writer.write(message + "\n");
+ socket.shutdownOutput();
+ byte[] buffer = new byte[1024];
+ int length;
+ StringBuilder sb = new StringBuilder();
+ while((length=is.read(buffer))>-1){
+ sb.append(new String(buffer, 0, length));
+ }
+ String answer = sb.toString();
+ System.out.println(answer);
+ } catch (IOException ex) {
+ String labelText = topLabel.getText();
+ topLabel.setText("" + labelText + "");
+ Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ private String getCurrentTime(){
+ Date currentDate = new Date(System.currentTimeMillis());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");
+ String time = dateFormat.format(currentDate);
+ return time;
+ }
+
+ public void exit(){
+ isExit = true;
+ }
+}
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientFrame.java b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientFrame.java
new file mode 100644
index 0000000..c83daae
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientFrame.java
@@ -0,0 +1,93 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group1;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import javax.swing.*;
+
+/**
+ *
+ * @author Denis
+ */
+public class ClientFrame extends JFrame{
+
+ private final JMenuBar menuBar;
+ private final JMenu menu;
+ private final JMenuItem itemExit;
+ private final JMenuItem itemServerHost;
+ private final JButton send;
+ private final JTextField messageText;
+ private final JTextArea chatingText;
+ private final JLabel topLabel;
+
+ private String serverHost;
+ private int serverPort;
+ private String username;
+
+ public ClientFrame(){
+ super("Chat client");
+ setSize(500, 700);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ getSettings();
+ setLayout(new BorderLayout());
+ topLabel = new JLabel(serverHost + ":" + serverPort + " >>> " + username);
+
+ if(username==null) {
+ ClientProperties.getState().setUsername(JOptionPane.showInputDialog(this, "Введите имя пользователя"));
+ getSettings();
+ topLabel.setText(serverHost + ":" + serverPort + " >>> " + username);
+ }
+
+ menuBar = new JMenuBar();
+ menu = new JMenu("File");
+ itemExit = new JMenuItem("Exit");
+ itemServerHost = new JMenuItem("Server settings");
+ setJMenuBar(menuBar);
+ menuBar.add(menu);
+ menu.add(itemExit);
+ menu.add(itemServerHost);
+ chatingText = new JTextArea();
+ messageText = new JTextField(" ");
+ send = new JButton("Send");
+
+ add(topLabel, BorderLayout.NORTH);
+ chatingText.setEditable(false);
+ add(chatingText, BorderLayout.CENTER);
+
+ messageText.setColumns(30);
+
+ JPanel bottom = new JPanel(new FlowLayout());
+ bottom.add(messageText);
+ bottom.add(send);
+
+ add(bottom, BorderLayout.SOUTH);
+ addListeners();
+ setLocationRelativeTo(null);
+ setVisible(true);
+ ChatServer.getState(topLabel, chatingText);
+ }
+
+ private void addListeners(){
+ itemExit.addActionListener(e -> {
+ ChatServer.getState(topLabel, chatingText).exit();
+ dispose();
+ });
+ itemServerHost.addActionListener(e -> {
+ topLabel.setText(JOptionPane.showInputDialog(this, "Введите ip-адрес сервера"));
+ });
+ send.addActionListener(e -> {
+ String message = messageText.getText();
+ ChatServer.getState(topLabel, chatingText).sendMessage(message);
+ });
+ }
+
+ private void getSettings(){
+ serverHost = ClientProperties.getState().getServerHost();
+ serverPort = ClientProperties.getState().getServerPort();
+ username = ClientProperties.getState().getUsername();
+ }
+}
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientProperties.java b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientProperties.java
new file mode 100644
index 0000000..3514cdb
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/ClientProperties.java
@@ -0,0 +1,73 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group1;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Denis
+ */
+public class ClientProperties {
+ private final Properties properties;
+ private final static ClientProperties propertyState = new ClientProperties();
+ private final File propertyFile;
+
+ private ClientProperties(){
+ properties = new Properties();
+ String path = Paths.get("").toAbsolutePath().toString() + File.separator + "client.property";
+ propertyFile = new File(path);
+ try {
+ if(!propertyFile.exists()){
+ propertyFile.createNewFile();
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(ClientProperties.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+
+ public final static ClientProperties getState(){
+ return propertyState;
+ }
+
+ public String getServerHost(){
+ try {properties.load(new FileReader(propertyFile));} catch (IOException ex) {}
+ return properties.getProperty("host", "188.134.85.87");
+ }
+ public int getServerPort(){
+ try {properties.load(new FileReader(propertyFile));} catch (IOException ex) {}
+ String port = properties.getProperty("port", "8092");
+ return port.matches("\\d+") ? Integer.valueOf(port) : 7007;
+ }
+
+ public String getUsername(){
+ try {properties.load(new FileReader(propertyFile));} catch (IOException ex) {}
+ return properties.getProperty("username");
+ }
+
+ public void setServerHost(String severHost){
+ properties.setProperty("host", severHost);
+ try {properties.store(new FileWriter(propertyFile), null);} catch (IOException ex) {}
+ }
+
+ public void setServerPort(String severPort){
+ properties.setProperty("port", severPort);
+ try {properties.store(new FileWriter(propertyFile), null);} catch (IOException ex) {}
+ }
+
+ public void setUsername(String username){
+ properties.setProperty("username", username);
+ try {properties.store(new FileWriter(propertyFile), null);} catch (IOException ex) {}
+ }
+}
diff --git a/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/MainClass.java b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/MainClass.java
new file mode 100644
index 0000000..b4d673d
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatClientJ130_lesson4_group1/src/chatclientj130_lesson4_group1/MainClass.java
@@ -0,0 +1,21 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group1;
+
+/**
+ *
+ * @author Denis
+ */
+public class MainClass {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ new ClientFrame();
+ }
+
+}
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build.xml b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build.xml
new file mode 100644
index 0000000..0eb2617
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project ChatServerJ130_lesson4_group1.
+
+
+
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/built-jar.properties b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/built-jar.properties
new file mode 100644
index 0000000..6ce33e6
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/built-jar.properties
@@ -0,0 +1,4 @@
+#Wed, 25 Jan 2023 21:19:31 +0300
+
+
+C\:\\Users\\denis.LAPTOP-4LI8UQ4O\\OneDrive\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\NetBeansProjects\\ChatServerJ130_lesson4_group1=
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/ClientSocket.class b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/ClientSocket.class
new file mode 100644
index 0000000..3655fc3
Binary files /dev/null and b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/ClientSocket.class differ
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/MainClass.class b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/MainClass.class
new file mode 100644
index 0000000..b2d055e
Binary files /dev/null and b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/MainClass.class differ
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/Message.class b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/Message.class
new file mode 100644
index 0000000..514be93
Binary files /dev/null and b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/Message.class differ
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/MessageStore.class b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/MessageStore.class
new file mode 100644
index 0000000..021bb77
Binary files /dev/null and b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/MessageStore.class differ
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/PortListener.class b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/PortListener.class
new file mode 100644
index 0000000..9c2f281
Binary files /dev/null and b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/build/classes/chatserverj130_lesson4_group1/PortListener.class differ
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/dist/ChatServerJ130_lesson4_group1.jar b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/dist/ChatServerJ130_lesson4_group1.jar
new file mode 100644
index 0000000..a3d9bcd
Binary files /dev/null and b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/dist/ChatServerJ130_lesson4_group1.jar differ
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/dist/README.TXT b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/dist/README.TXT
new file mode 100644
index 0000000..061f5d9
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/dist/README.TXT
@@ -0,0 +1,32 @@
+========================
+BUILD OUTPUT DESCRIPTION
+========================
+
+When you build an Java application project that has a main class, the IDE
+automatically copies all of the JAR
+files on the projects classpath to your projects dist/lib folder. The IDE
+also adds each of the JAR files to the Class-Path element in the application
+JAR files manifest file (MANIFEST.MF).
+
+To run the project from the command line, go to the dist folder and
+type the following:
+
+java -jar "ChatServerJ130_lesson4_group1.jar"
+
+To distribute this project, zip up the dist folder (including the lib folder)
+and distribute the ZIP file.
+
+Notes:
+
+* If two JAR files on the project classpath have the same name, only the first
+JAR file is copied to the lib folder.
+* Only JAR files are copied to the lib folder.
+If the classpath contains other types of files or folders, these files (folders)
+are not copied.
+* If a library on the projects classpath also has a Class-Path element
+specified in the manifest,the content of the Class-Path element has to be on
+the projects runtime path.
+* To set a main class in a standard Java project, right-click the project node
+in the Projects window and choose Properties. Then click Run and enter the
+class name in the Main Class field. Alternatively, you can manually type the
+class name in the manifest Main-Class element.
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/manifest.mf b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/build-impl.xml b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/build-impl.xml
new file mode 100644
index 0000000..57d6742
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/genfiles.properties b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/genfiles.properties
new file mode 100644
index 0000000..25075b1
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=c2fa2be0
+build.xml.script.CRC32=cf302020
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=c2fa2be0
+nbproject/build-impl.xml.script.CRC32=6be3a0a1
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/private/private.properties b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/private/private.xml b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/private/private.xml
new file mode 100644
index 0000000..740cce2
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/private/private.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/ClientSocket.java
+ file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MainClass.java
+
+
+
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/project.properties b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/project.properties
new file mode 100644
index 0000000..2fa502f
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/ChatServerJ130_lesson4_group1.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=chatserverj130_lesson4_group1.MainClass
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/project.xml b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/project.xml
new file mode 100644
index 0000000..476dd4a
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ ChatServerJ130_lesson4_group1
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/ClientSocket.java b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/ClientSocket.java
new file mode 100644
index 0000000..e817f7f
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/ClientSocket.java
@@ -0,0 +1,62 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group1;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.Socket;
+
+/**
+ *
+ * @author Denis
+ */
+public class ClientSocket {
+
+ public void client(Socket socket){
+ try(//BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ InputStream is = socket.getInputStream();
+ OutputStream os = socket.getOutputStream();){
+ byte[] buffer = new byte[1024];
+ int length;
+ StringBuilder sb = new StringBuilder();
+ while((length=is.read(buffer))>-1){
+ sb.append(new String(buffer, 0, length));
+ }
+ String message = sb.toString();
+ //String message = reader.readLine();
+ socket.shutdownInput();
+ int type = typeMessage(message);
+ if(type==1) {
+ String history = MessageStore.getState().getAllMessage();
+ buffer = history.getBytes();
+ os.write(buffer);
+ }
+ if(type==2) {
+ message = message.replace("post", "").trim();
+ MessageStore.addMessage(message);
+ buffer = "OK".getBytes();
+ os.write(buffer);
+ }
+ if(type==9) {
+ buffer = "ERROR".getBytes();
+ os.write(buffer);
+ }
+ }catch(IOException ioe){}
+ }
+
+ private int typeMessage(String message){
+ if(message!=null){
+ if(message.startsWith("get")) return 1;
+ if(message.startsWith("post")) return 2;
+ }
+ return 9;
+ }
+}
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MainClass.java b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MainClass.java
new file mode 100644
index 0000000..355d488
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MainClass.java
@@ -0,0 +1,25 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group1;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ * @author Denis
+ */
+public class MainClass {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ PortListener.startListener();
+ }
+}
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/Message.java b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/Message.java
new file mode 100644
index 0000000..2419415
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/Message.java
@@ -0,0 +1,85 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group1;
+
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ *
+ * @author Denis
+ */
+public class Message implements Comparable{
+ private String user;
+ private Date time;
+ private String text;
+
+ public String getUser() {
+ return user;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+
+
+ @Override
+ public int compareTo(Message o) {
+ return this.time.compareTo(o.time);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 11 * hash + Objects.hashCode(this.user);
+ hash = 11 * hash + Objects.hashCode(this.time);
+ hash = 11 * hash + Objects.hashCode(this.text);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Message other = (Message) obj;
+ if (!Objects.equals(this.user, other.user)) {
+ return false;
+ }
+ if (!Objects.equals(this.text, other.text)) {
+ return false;
+ }
+ if (!Objects.equals(this.time, other.time)) {
+ return false;
+ }
+ return true;
+ }
+
+
+}
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MessageStore.java b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MessageStore.java
new file mode 100644
index 0000000..9678747
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/MessageStore.java
@@ -0,0 +1,49 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group1;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ *
+ * @author Denis
+ */
+public class MessageStore {
+ private static final MessageStore store = new MessageStore();
+ public Set mesages = new TreeSet<>();
+
+ private MessageStore(){}
+
+ public static MessageStore getState(){
+ return store;
+ }
+
+ public static boolean addMessage(String text){
+ Message mesObj = new Message();
+ String[] mes = text.split(">>");
+ if(mes.length<3) return false;
+ mesObj.setUser(mes[0].replace("get", "").trim());
+ mesObj.setTime(new Date(System.currentTimeMillis()));
+ mesObj.setText(mes[2].trim());
+ store.mesages.add(mesObj);
+ return true;
+ }
+
+ public String getAllMessage(){
+ SimpleDateFormat format = new SimpleDateFormat("yy.MM.dd hh:mm:ss");
+ StringBuilder sb = new StringBuilder();
+ mesages.forEach(message -> {
+ sb.append(message.getUser()).append(" >>> ")
+ .append(format.format(message.getTime()))
+ .append(" \n").append("\t")
+ .append(message.getText()).append("\n");
+ });
+ return sb.toString();
+ }
+}
diff --git a/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/PortListener.java b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/PortListener.java
new file mode 100644
index 0000000..73a781f
--- /dev/null
+++ b/java/samples/tcp/Chat/ChatServerJ130_lesson4_group1/src/chatserverj130_lesson4_group1/PortListener.java
@@ -0,0 +1,57 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group1;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Denis
+ */
+public final class PortListener implements Runnable{
+
+ private static PortListener portListener;
+ private static boolean stop;
+ private Thread thread;
+
+ private PortListener(){
+ stop = false;
+ thread = new Thread(portListener);
+ }
+
+ public static PortListener getState(){
+ return portListener;
+ }
+
+ public synchronized static void startListener(){
+ if(portListener==null) {
+ portListener = new PortListener();
+ portListener.thread = new Thread(portListener);
+ portListener.thread.start();
+ }
+ if(portListener.thread.getState().toString().equals("TERMINATED")){
+ portListener.thread = new Thread(portListener);
+ portListener.thread.start();
+ }
+ }
+
+ @Override
+ public void run() {
+ try (ServerSocket serverSocket = new ServerSocket(8092)) {
+ while(!stop){
+ Socket newSocket = serverSocket.accept();
+ new ClientSocket().client(newSocket);
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(PortListener.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build.xml b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build.xml
new file mode 100644
index 0000000..2ef573f
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project ChatClientJ130_lesson4_group2.
+
+
+
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/built-jar.properties b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/built-jar.properties
new file mode 100644
index 0000000..002e572
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/built-jar.properties
@@ -0,0 +1,4 @@
+#Fri, 27 Jan 2023 21:07:39 +0300
+
+
+C\:\\Users\\denis.LAPTOP-4LI8UQ4O\\OneDrive\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\NetBeansProjects\\ChatClientJ130_lesson4_group2=
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ChatServer.class b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ChatServer.class
new file mode 100644
index 0000000..0985408
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ChatServer.class differ
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ClientFrame.class b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ClientFrame.class
new file mode 100644
index 0000000..817b904
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ClientFrame.class differ
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ClientProperties.class b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ClientProperties.class
new file mode 100644
index 0000000..dc2168b
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/ClientProperties.class differ
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/MainClass.class b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/MainClass.class
new file mode 100644
index 0000000..f29f4cd
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/build/classes/chatclientj130_lesson4_group2/MainClass.class differ
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/client.property b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/client.property
new file mode 100644
index 0000000..79d133d
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/client.property
@@ -0,0 +1,2 @@
+#Fri Jan 27 20:09:17 MSK 2023
+username=Denis
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/dist/ChatClientJ130_lesson4_group2.jar b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/dist/ChatClientJ130_lesson4_group2.jar
new file mode 100644
index 0000000..de6bbc8
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/dist/ChatClientJ130_lesson4_group2.jar differ
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/dist/README.TXT b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/dist/README.TXT
new file mode 100644
index 0000000..f6f05e3
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/dist/README.TXT
@@ -0,0 +1,32 @@
+========================
+BUILD OUTPUT DESCRIPTION
+========================
+
+When you build an Java application project that has a main class, the IDE
+automatically copies all of the JAR
+files on the projects classpath to your projects dist/lib folder. The IDE
+also adds each of the JAR files to the Class-Path element in the application
+JAR files manifest file (MANIFEST.MF).
+
+To run the project from the command line, go to the dist folder and
+type the following:
+
+java -jar "ChatClientJ130_lesson4_group2.jar"
+
+To distribute this project, zip up the dist folder (including the lib folder)
+and distribute the ZIP file.
+
+Notes:
+
+* If two JAR files on the project classpath have the same name, only the first
+JAR file is copied to the lib folder.
+* Only JAR files are copied to the lib folder.
+If the classpath contains other types of files or folders, these files (folders)
+are not copied.
+* If a library on the projects classpath also has a Class-Path element
+specified in the manifest,the content of the Class-Path element has to be on
+the projects runtime path.
+* To set a main class in a standard Java project, right-click the project node
+in the Projects window and choose Properties. Then click Run and enter the
+class name in the Main Class field. Alternatively, you can manually type the
+class name in the manifest Main-Class element.
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/manifest.mf b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/build-impl.xml b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/build-impl.xml
new file mode 100644
index 0000000..79265d1
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/genfiles.properties b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/genfiles.properties
new file mode 100644
index 0000000..a2b19ea
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=19595f86
+build.xml.script.CRC32=2b14b91d
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=19595f86
+nbproject/build-impl.xml.script.CRC32=eb95a494
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/private/private.properties b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/project.properties b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/project.properties
new file mode 100644
index 0000000..f4eda07
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/ChatClientJ130_lesson4_group2.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=chatclientj130_lesson4_group2.MainClass
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/project.xml b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/project.xml
new file mode 100644
index 0000000..580b4b5
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ ChatClientJ130_lesson4_group2
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ChatServer.java b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ChatServer.java
new file mode 100644
index 0000000..dd5ae4b
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ChatServer.java
@@ -0,0 +1,111 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group2;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.Socket;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JLabel;
+import javax.swing.JTextArea;
+
+/**
+ *
+ * @author Denis
+ */
+public class ChatServer implements Runnable{
+
+ private static ChatServer chatServer;
+ private boolean isExit = false;
+ private JLabel topLabel;
+ private JTextArea chatingText;
+
+ private ChatServer(JLabel topLabel, JTextArea chatingText){
+ this.chatingText = chatingText;
+ this.topLabel = topLabel;
+ }
+
+ public static ChatServer getState(JLabel topLabel, JTextArea chatingText){
+ Thread thread = null;
+ if(chatServer==null) {
+ chatServer = new ChatServer(topLabel, chatingText);
+ thread = new Thread(chatServer);
+ thread.start();
+ }
+ if(thread!=null && thread.getState().toString().equals("TERMINATED")){
+ thread = new Thread(chatServer);
+ thread.start();
+ }
+ return chatServer;
+ }
+
+ @Override
+ public void run() {
+ while(!isExit){
+ updateChat();
+ try {Thread.sleep(1000);} catch (InterruptedException ex) {}
+ }
+ }
+
+ private void updateChat(){
+ try (Socket socket = new Socket(ClientProperties.getState().getServerHost(), ClientProperties.getState().getServerPort());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));){
+ String labelText = topLabel.getText();
+ if(socket.isConnected()) topLabel.setText("" + labelText + "");
+ writer.write("get messages" + "\n");
+ writer.flush();
+ StringBuilder sb = new StringBuilder();
+ String temp;
+ while((temp = reader.readLine())!=null){
+ sb.append(temp).append("\n");
+ }
+ chatingText.setText(sb.toString());
+ } catch (IOException ex) {
+ String labelText = topLabel.getText();
+ topLabel.setText("" + labelText + "");
+ Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public void sendMessage(String message){
+ String username = ClientProperties.getState().getUsername();
+ message = "post" + username + " >> " + getCurrentTime() + " >> " + message;
+ try (Socket socket = new Socket(ClientProperties.getState().getServerHost(), ClientProperties.getState().getServerPort());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));){
+ String labelText = topLabel.getText();
+ if(socket.isConnected()) topLabel.setText("" + labelText + "");
+ writer.write(message + "\n");
+ writer.flush();
+ String answer = reader.readLine();
+ //chatingText.append(answer + System.lineSeparator());
+ reader.close();
+ writer.close();
+ } catch (IOException ex) {
+ String labelText = topLabel.getText();
+ topLabel.setText("" + labelText + "");
+ Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ private String getCurrentTime(){
+ Date currentDate = new Date(System.currentTimeMillis());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");
+ String time = dateFormat.format(currentDate);
+ return time;
+ }
+
+ public void exit(){
+ isExit = true;
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ClientFrame.java b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ClientFrame.java
new file mode 100644
index 0000000..793f9c5
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ClientFrame.java
@@ -0,0 +1,92 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group2;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import javax.swing.*;
+
+/**
+ *
+ * @author Denis
+ */
+public class ClientFrame extends JFrame{
+
+ private final JMenuBar menuBar;
+ private final JMenu menu;
+ private final JMenuItem itemExit;
+ private final JMenuItem itemServerHost;
+ private final JButton send;
+ private final JTextField messageText;
+ private final JTextArea chatingText;
+ private final JLabel topLabel;
+
+ private String serverHost;
+ private int serverPort;
+ private String username;
+
+ public ClientFrame(){
+ super("Chat client");
+ setSize(500, 700);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ getSettings();
+ setLayout(new BorderLayout());
+ topLabel = new JLabel(serverHost + ":" + serverPort + " >>> " + username);
+
+ if(username==null) {
+ ClientProperties.getState().setUsername(JOptionPane.showInputDialog(this, "Введите имя пользователя"));
+ getSettings();
+ topLabel.setText(serverHost + ":" + serverPort + " >>> " + username);
+ }
+
+ menuBar = new JMenuBar();
+ menu = new JMenu("File");
+ itemExit = new JMenuItem("Exit");
+ itemServerHost = new JMenuItem("Server settings");
+ setJMenuBar(menuBar);
+ menuBar.add(menu);
+ menu.add(itemExit);
+ menu.add(itemServerHost);
+ chatingText = new JTextArea();
+ messageText = new JTextField(" ");
+ send = new JButton("Send");
+
+ add(topLabel, BorderLayout.NORTH);
+ chatingText.setEditable(false);
+ add(chatingText, BorderLayout.CENTER);
+
+ messageText.setColumns(30);
+
+ JPanel bottom = new JPanel(new FlowLayout());
+ bottom.add(messageText);
+ bottom.add(send);
+
+ add(bottom, BorderLayout.SOUTH);
+ addListeners();
+ setLocationRelativeTo(null);
+ setVisible(true);
+ }
+
+ private void addListeners(){
+ itemExit.addActionListener(e -> {
+ ChatServer.getState(topLabel, chatingText).exit();
+ dispose();
+ });
+ itemServerHost.addActionListener(e -> {
+ topLabel.setText(JOptionPane.showInputDialog(this, "Введите ip-адрес сервера"));
+ });
+ send.addActionListener(e -> {
+ String message = messageText.getText();
+ ChatServer.getState(topLabel, chatingText).sendMessage(message);
+ });
+ }
+
+ private void getSettings(){
+ serverHost = ClientProperties.getState().getServerHost();
+ serverPort = ClientProperties.getState().getServerPort();
+ username = ClientProperties.getState().getUsername();
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ClientProperties.java b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ClientProperties.java
new file mode 100644
index 0000000..fd6c2c6
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/ClientProperties.java
@@ -0,0 +1,73 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group2;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Denis
+ */
+public class ClientProperties {
+ private final Properties properties;
+ private final static ClientProperties propertyState = new ClientProperties();
+ private final File propertyFile;
+
+ private ClientProperties(){
+ properties = new Properties();
+ String path = Paths.get("").toAbsolutePath().toString() + File.separator + "client.property";
+ propertyFile = new File(path);
+ try {
+ if(!propertyFile.exists()){
+ propertyFile.createNewFile();
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(ClientProperties.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+
+ public final static ClientProperties getState(){
+ return propertyState;
+ }
+
+ public String getServerHost(){
+ try {properties.load(new FileReader(propertyFile));} catch (IOException ex) {}
+ return properties.getProperty("host", "188.134.85.87");
+ }
+ public int getServerPort(){
+ try {properties.load(new FileReader(propertyFile));} catch (IOException ex) {}
+ String port = properties.getProperty("port", "8092");
+ return port.matches("\\d+") ? Integer.valueOf(port) : 7007;
+ }
+
+ public String getUsername(){
+ try {properties.load(new FileReader(propertyFile));} catch (IOException ex) {}
+ return properties.getProperty("username");
+ }
+
+ public void setServerHost(String severHost){
+ properties.setProperty("host", severHost);
+ try {properties.store(new FileWriter(propertyFile), null);} catch (IOException ex) {}
+ }
+
+ public void setServerPort(String severPort){
+ properties.setProperty("port", severPort);
+ try {properties.store(new FileWriter(propertyFile), null);} catch (IOException ex) {}
+ }
+
+ public void setUsername(String username){
+ properties.setProperty("username", username);
+ try {properties.store(new FileWriter(propertyFile), null);} catch (IOException ex) {}
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/MainClass.java b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/MainClass.java
new file mode 100644
index 0000000..d94a2d2
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatClientJ130_lesson4_group2/src/chatclientj130_lesson4_group2/MainClass.java
@@ -0,0 +1,21 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatclientj130_lesson4_group2;
+
+/**
+ *
+ * @author Denis
+ */
+public class MainClass {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ new ClientFrame();
+ }
+
+}
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build.xml b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build.xml
new file mode 100644
index 0000000..13053b9
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project ChatServerJ130_lesson4_group2.
+
+
+
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/built-jar.properties b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/built-jar.properties
new file mode 100644
index 0000000..383565b
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/built-jar.properties
@@ -0,0 +1,4 @@
+#Fri, 27 Jan 2023 20:58:17 +0300
+
+
+C\:\\Users\\denis.LAPTOP-4LI8UQ4O\\OneDrive\\\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b\\NetBeansProjects\\ChatServerJ130_lesson4_group2=
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/ClientSocket.class b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/ClientSocket.class
new file mode 100644
index 0000000..8a1e8ec
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/ClientSocket.class differ
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/MainClass.class b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/MainClass.class
new file mode 100644
index 0000000..079bae7
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/MainClass.class differ
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/Message.class b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/Message.class
new file mode 100644
index 0000000..576933f
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/Message.class differ
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/MessageStore.class b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/MessageStore.class
new file mode 100644
index 0000000..085e434
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/MessageStore.class differ
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/PortListener.class b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/PortListener.class
new file mode 100644
index 0000000..f14549c
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/build/classes/chatserverj130_lesson4_group2/PortListener.class differ
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/dist/ChatServerJ130_lesson4_group2.jar b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/dist/ChatServerJ130_lesson4_group2.jar
new file mode 100644
index 0000000..54fe527
Binary files /dev/null and b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/dist/ChatServerJ130_lesson4_group2.jar differ
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/dist/README.TXT b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/dist/README.TXT
new file mode 100644
index 0000000..0cff89c
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/dist/README.TXT
@@ -0,0 +1,32 @@
+========================
+BUILD OUTPUT DESCRIPTION
+========================
+
+When you build an Java application project that has a main class, the IDE
+automatically copies all of the JAR
+files on the projects classpath to your projects dist/lib folder. The IDE
+also adds each of the JAR files to the Class-Path element in the application
+JAR files manifest file (MANIFEST.MF).
+
+To run the project from the command line, go to the dist folder and
+type the following:
+
+java -jar "ChatServerJ130_lesson4_group2.jar"
+
+To distribute this project, zip up the dist folder (including the lib folder)
+and distribute the ZIP file.
+
+Notes:
+
+* If two JAR files on the project classpath have the same name, only the first
+JAR file is copied to the lib folder.
+* Only JAR files are copied to the lib folder.
+If the classpath contains other types of files or folders, these files (folders)
+are not copied.
+* If a library on the projects classpath also has a Class-Path element
+specified in the manifest,the content of the Class-Path element has to be on
+the projects runtime path.
+* To set a main class in a standard Java project, right-click the project node
+in the Projects window and choose Properties. Then click Run and enter the
+class name in the Main Class field. Alternatively, you can manually type the
+class name in the manifest Main-Class element.
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/manifest.mf b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/build-impl.xml b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/build-impl.xml
new file mode 100644
index 0000000..d483093
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/genfiles.properties b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/genfiles.properties
new file mode 100644
index 0000000..d4ce13c
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=dacebf8a
+build.xml.script.CRC32=78491380
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=dacebf8a
+nbproject/build-impl.xml.script.CRC32=d1670449
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/private/private.properties b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/project.properties b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/project.properties
new file mode 100644
index 0000000..0c78f09
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/ChatServerJ130_lesson4_group2.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=chatserverj130_lesson4_group2.MainClass
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/project.xml b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/project.xml
new file mode 100644
index 0000000..538c0dc
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ ChatServerJ130_lesson4_group2
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/ClientSocket.java b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/ClientSocket.java
new file mode 100644
index 0000000..7b2f685
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/ClientSocket.java
@@ -0,0 +1,42 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group2;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.Socket;
+
+/**
+ *
+ * @author Denis
+ */
+public class ClientSocket {
+
+ public void client(Socket socket){
+ try(BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));){
+ String message = reader.readLine();
+ int type = typeMessage(message);
+ if(type==1) writer.write(MessageStore.getState().getAllMessage());
+ if(type==2) {
+ message = message.replace("post", "").trim();
+ MessageStore.addMessage(message);
+ writer.write("OK");
+ }
+ if(type==9) writer.write("ERROR");
+ writer.flush();
+ }catch(IOException ioe){}
+ }
+
+ private int typeMessage(String message){
+ if(message.startsWith("get")) return 1;
+ if(message.startsWith("post")) return 2;
+ return 9;
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/MainClass.java b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/MainClass.java
new file mode 100644
index 0000000..ee21280
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/MainClass.java
@@ -0,0 +1,34 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group2;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ * @author Denis
+ */
+public class MainClass {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+// PortListener listener = PortListener.getState();
+// Thread thread = new Thread(listener);
+// thread.start();
+ PortListener.startListener();
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ PortListener.startListener();
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/Message.java b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/Message.java
new file mode 100644
index 0000000..857ad16
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/Message.java
@@ -0,0 +1,85 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group2;
+
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ *
+ * @author Denis
+ */
+public class Message implements Comparable{
+ private String user;
+ private Date time;
+ private String text;
+
+ public String getUser() {
+ return user;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+
+
+ @Override
+ public int compareTo(Message o) {
+ return this.time.compareTo(o.time);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 11 * hash + Objects.hashCode(this.user);
+ hash = 11 * hash + Objects.hashCode(this.time);
+ hash = 11 * hash + Objects.hashCode(this.text);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Message other = (Message) obj;
+ if (!Objects.equals(this.user, other.user)) {
+ return false;
+ }
+ if (!Objects.equals(this.text, other.text)) {
+ return false;
+ }
+ if (!Objects.equals(this.time, other.time)) {
+ return false;
+ }
+ return true;
+ }
+
+
+}
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/MessageStore.java b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/MessageStore.java
new file mode 100644
index 0000000..98fe82f
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/MessageStore.java
@@ -0,0 +1,48 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group2;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ *
+ * @author Denis
+ */
+public class MessageStore {
+ private static final MessageStore store = new MessageStore();
+ public Set mesages = new TreeSet<>();
+
+ private MessageStore(){}
+
+ public static MessageStore getState(){
+ return store;
+ }
+
+ public static boolean addMessage(String text){
+ Message mesObj = new Message();
+ String[] mes = text.split(">>");
+ if(mes.length<3) return false;
+ mesObj.setUser(mes[0].replace("get", "").trim());
+ mesObj.setTime(new Date(System.currentTimeMillis()));
+ mesObj.setText(mes[2].trim());
+ store.mesages.add(mesObj);
+ return true;
+ }
+
+ public String getAllMessage(){
+ SimpleDateFormat format = new SimpleDateFormat("yy.MM.dd HH:mm:ss");
+ StringBuilder sb = new StringBuilder();
+ mesages.forEach(message -> {
+ sb.append(message.getUser()).append(" >>> ")
+ .append(format.format(message.getTime())).append(" >>> \n\t")
+ .append(message.getText()).append("\n");
+ });
+ return sb.toString();
+ }
+}
diff --git a/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/PortListener.java b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/PortListener.java
new file mode 100644
index 0000000..375870d
--- /dev/null
+++ b/java/samples/tcp/Chat2/ChatServerJ130_lesson4_group2/src/chatserverj130_lesson4_group2/PortListener.java
@@ -0,0 +1,52 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatserverj130_lesson4_group2;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Denis
+ */
+public final class PortListener implements Runnable{
+
+ private static PortListener portListener;
+ private static boolean stop;
+ private Thread thread;
+
+ private PortListener(){
+ stop = false;
+ thread = new Thread(portListener);
+ }
+
+ public synchronized final static void startListener(){
+ if(portListener==null) {
+ portListener = new PortListener();
+ portListener.thread = new Thread(portListener);
+ portListener.thread.start();
+ }
+ if(portListener.thread.getState().toString().equals("TERMINATED")){
+ portListener.thread = new Thread(portListener);
+ portListener.thread.start();
+ }
+ }
+
+ @Override
+ public void run() {
+ try (ServerSocket serverSocket = new ServerSocket(8092)) {
+ while(!stop){
+ Socket newSocket = serverSocket.accept();
+ new ClientSocket().client(newSocket);
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(PortListener.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+}
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build.xml b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build.xml
new file mode 100644
index 0000000..6a6995b
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project NetworkTransferClient.
+
+
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/.netbeans_automatic_build b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/.netbeans_update_resources b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/networktransferclient/NetworkTransferClient.class b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/networktransferclient/NetworkTransferClient.class
new file mode 100644
index 0000000..2b45073
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/build/classes/networktransferclient/NetworkTransferClient.class differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab1.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab1.pdf
new file mode 100644
index 0000000..6fd587c
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab1.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab2-2.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab2-2.pdf
new file mode 100644
index 0000000..d1dee7e
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab2-2.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab2.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab2.pdf
new file mode 100644
index 0000000..43df569
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab2.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab3.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab3.pdf
new file mode 100644
index 0000000..df61bb1
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab3.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab4.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab4.pdf
new file mode 100644
index 0000000..4e81968
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/j130-lab4.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/manifest.mf b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/build-impl.xml b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/build-impl.xml
new file mode 100644
index 0000000..1923e56
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/genfiles.properties b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/genfiles.properties
new file mode 100644
index 0000000..3b7c85c
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=29cf46d3
+build.xml.script.CRC32=b109d07b
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=29cf46d3
+nbproject/build-impl.xml.script.CRC32=bd8087d6
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/private/private.properties b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/project.properties b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/project.properties
new file mode 100644
index 0000000..ff0ffb8
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/NetworkTransferClient.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=networktransferclient.NetworkTransferClient
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/project.xml b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/project.xml
new file mode 100644
index 0000000..9b7a4c0
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ NetworkTransferClient
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferClient/src/networktransferclient/NetworkTransferClient.java b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/src/networktransferclient/NetworkTransferClient.java
new file mode 100644
index 0000000..9ca08ca
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferClient/src/networktransferclient/NetworkTransferClient.java
@@ -0,0 +1,52 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package networktransferclient;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Socket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author denis
+ */
+public class NetworkTransferClient {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ try ( Socket socket = new Socket("127.0.0.1", 15001);
+ DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));){
+
+ File file = new File("j130-lab2.pdf");
+ if(file.exists()) {
+ dataOutputStream.writeUTF(file.getName());
+ byte[] buffer = new byte[1024];
+ try(FileInputStream fis = new FileInputStream(file)){
+ int length;
+ while((length=fis.read(buffer))>-1){
+ dataOutputStream.write(buffer, 0, length);
+ }
+ }
+ socket.shutdownOutput();
+ String msg = reader.readLine();
+ System.out.println("Получен ответ от сервера: " + msg);
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(NetworkTransferClient.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+}
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build.xml b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build.xml
new file mode 100644
index 0000000..66c1d5c
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project NetworkTransferServer.
+
+
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/.netbeans_automatic_build b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/.netbeans_update_resources b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/networktransferserver/NetworkTransferServer.class b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/networktransferserver/NetworkTransferServer.class
new file mode 100644
index 0000000..75bf894
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/build/classes/networktransferserver/NetworkTransferServer.class differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab1.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab1.pdf
new file mode 100644
index 0000000..6fd587c
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab1.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab2.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab2.pdf
new file mode 100644
index 0000000..43df569
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab2.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab3.pdf b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab3.pdf
new file mode 100644
index 0000000..df61bb1
Binary files /dev/null and b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/j130-lab3.pdf differ
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/manifest.mf b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/build-impl.xml b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/build-impl.xml
new file mode 100644
index 0000000..b9339a3
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/genfiles.properties b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/genfiles.properties
new file mode 100644
index 0000000..5e7d497
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=fe91e2c4
+build.xml.script.CRC32=be808369
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=fe91e2c4
+nbproject/build-impl.xml.script.CRC32=e3d5584c
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/private/private.properties b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/project.properties b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/project.properties
new file mode 100644
index 0000000..955ca83
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/NetworkTransferServer.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=networktransferserver.NetworkTransferServer
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/project.xml b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/project.xml
new file mode 100644
index 0000000..e2aed44
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ NetworkTransferServer
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/NetworkTransfer/NetworkTransferServer/src/networktransferserver/NetworkTransferServer.java b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/src/networktransferserver/NetworkTransferServer.java
new file mode 100644
index 0000000..d78f3e2
--- /dev/null
+++ b/java/samples/tcp/NetworkTransfer/NetworkTransferServer/src/networktransferserver/NetworkTransferServer.java
@@ -0,0 +1,76 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package networktransferserver;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author denis
+ */
+public class NetworkTransferServer implements Runnable{
+ private final Socket clientSocket;
+
+ public NetworkTransferServer(Socket clientSocket){
+ this.clientSocket = clientSocket;
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ ServerSocket serverSocket = new ServerSocket(15001);
+ while(true){
+ Socket socket = serverSocket.accept();
+ NetworkTransferServer transferServer = new NetworkTransferServer(socket);
+ Thread thread = new Thread(transferServer);
+ thread.start();
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(NetworkTransferServer.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public void clientSocket(){
+ try( Socket socket = clientSocket;
+ DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));){
+ String filename = dataInputStream.readUTF();
+ File file = new File(filename);
+ if(file.exists()) file.delete();
+ file.createNewFile();
+ try(FileOutputStream fos = new FileOutputStream(file) ){
+ byte[]buffer = new byte[1024];
+ int legth;
+ while((legth=dataInputStream.read(buffer))>-1){
+ fos.write(buffer, 0, legth);
+ }
+ }
+ socket.shutdownInput();
+ writer.write("OK");
+ } catch (IOException ex) {
+ Logger.getLogger(NetworkTransferServer.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ @Override
+ public void run() {
+ clientSocket();
+ }
+
+}
diff --git a/java/samples/tcp/NetworkTransferServer_2/build.xml b/java/samples/tcp/NetworkTransferServer_2/build.xml
new file mode 100644
index 0000000..f32868d
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project NetworkTransferServer_2.
+
+
+
diff --git a/java/samples/tcp/NetworkTransferServer_2/build/classes/.netbeans_automatic_build b/java/samples/tcp/NetworkTransferServer_2/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/NetworkTransferServer_2/build/classes/.netbeans_update_resources b/java/samples/tcp/NetworkTransferServer_2/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/java/samples/tcp/NetworkTransferServer_2/build/classes/networktransferserver_2/NetworkTransferServer_2.class b/java/samples/tcp/NetworkTransferServer_2/build/classes/networktransferserver_2/NetworkTransferServer_2.class
new file mode 100644
index 0000000..4a2060b
Binary files /dev/null and b/java/samples/tcp/NetworkTransferServer_2/build/classes/networktransferserver_2/NetworkTransferServer_2.class differ
diff --git a/java/samples/tcp/NetworkTransferServer_2/j130-lab1.pdf b/java/samples/tcp/NetworkTransferServer_2/j130-lab1.pdf
new file mode 100644
index 0000000..6fd587c
Binary files /dev/null and b/java/samples/tcp/NetworkTransferServer_2/j130-lab1.pdf differ
diff --git a/java/samples/tcp/NetworkTransferServer_2/j130-lab2-2.pdf b/java/samples/tcp/NetworkTransferServer_2/j130-lab2-2.pdf
new file mode 100644
index 0000000..d1dee7e
Binary files /dev/null and b/java/samples/tcp/NetworkTransferServer_2/j130-lab2-2.pdf differ
diff --git a/java/samples/tcp/NetworkTransferServer_2/j130-lab2.pdf b/java/samples/tcp/NetworkTransferServer_2/j130-lab2.pdf
new file mode 100644
index 0000000..43df569
Binary files /dev/null and b/java/samples/tcp/NetworkTransferServer_2/j130-lab2.pdf differ
diff --git a/java/samples/tcp/NetworkTransferServer_2/manifest.mf b/java/samples/tcp/NetworkTransferServer_2/manifest.mf
new file mode 100644
index 0000000..1574df4
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/java/samples/tcp/NetworkTransferServer_2/nbproject/build-impl.xml b/java/samples/tcp/NetworkTransferServer_2/nbproject/build-impl.xml
new file mode 100644
index 0000000..d2aecde
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/nbproject/build-impl.xml
@@ -0,0 +1,1420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/NetworkTransferServer_2/nbproject/genfiles.properties b/java/samples/tcp/NetworkTransferServer_2/nbproject/genfiles.properties
new file mode 100644
index 0000000..71aa14c
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=9e36b485
+build.xml.script.CRC32=47c5f5cc
+build.xml.stylesheet.CRC32=8064a381@1.80.1.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=9e36b485
+nbproject/build-impl.xml.script.CRC32=f54457ab
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/java/samples/tcp/NetworkTransferServer_2/nbproject/private/private.properties b/java/samples/tcp/NetworkTransferServer_2/nbproject/private/private.properties
new file mode 100644
index 0000000..11ff3b8
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/java/samples/tcp/NetworkTransferServer_2/nbproject/project.properties b/java/samples/tcp/NetworkTransferServer_2/nbproject/project.properties
new file mode 100644
index 0000000..3d15f26
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/nbproject/project.properties
@@ -0,0 +1,74 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/NetworkTransferServer_2.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.8
+javac.target=1.8
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=networktransferserver_2.NetworkTransferServer_2
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/java/samples/tcp/NetworkTransferServer_2/nbproject/project.xml b/java/samples/tcp/NetworkTransferServer_2/nbproject/project.xml
new file mode 100644
index 0000000..fac0c21
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ NetworkTransferServer_2
+
+
+
+
+
+
+
+
+
diff --git a/java/samples/tcp/NetworkTransferServer_2/src/networktransferserver_2/NetworkTransferServer_2.java b/java/samples/tcp/NetworkTransferServer_2/src/networktransferserver_2/NetworkTransferServer_2.java
new file mode 100644
index 0000000..a34d634
--- /dev/null
+++ b/java/samples/tcp/NetworkTransferServer_2/src/networktransferserver_2/NetworkTransferServer_2.java
@@ -0,0 +1,63 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package networktransferserver_2;
+
+import java.io.BufferedWriter;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author denis
+ */
+public class NetworkTransferServer_2 {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ ServerSocket serverSocket = new ServerSocket(7007);
+ while(true){
+ new NetworkTransferServer_2().work(serverSocket.accept());
+ }
+
+ } catch (IOException ex) {
+ Logger.getLogger(NetworkTransferServer_2.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ private void work(Socket socketClient){
+ try(Socket socket = socketClient;
+ DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))){
+ String filename = dataInputStream.readUTF();
+ File file = new File(filename);
+ if(file.exists()) file.delete();
+ file.createNewFile();
+ byte[] buffer = new byte[4096];
+ try(FileOutputStream fileoutput = new FileOutputStream(file) ){
+ int length;
+ while((length = dataInputStream.read(buffer))>-1){
+ fileoutput.write(buffer, 0, length);
+ }
+ }
+ socket.shutdownInput();
+ writer.write("OK");
+ }catch (IOException ex) {
+ Logger.getLogger(NetworkTransferServer_2.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+}