diff --git a/ClientAccademico/build.xml b/ClientAccademico/build.xml new file mode 100644 index 0000000..83965a8 --- /dev/null +++ b/ClientAccademico/build.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + Builds, tests, and runs the project ClientAccademico. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ClientAccademico/build/built-jar.properties b/ClientAccademico/build/built-jar.properties new file mode 100644 index 0000000..dd3cce3 --- /dev/null +++ b/ClientAccademico/build/built-jar.properties @@ -0,0 +1,4 @@ +#Wed, 01 Feb 2023 15:55:04 +0100 + + +/home/boss/Progetti/ClientAccademico= diff --git a/ClientAccademico/build/classes/.netbeans_automatic_build b/ClientAccademico/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/ClientAccademico/build/classes/.netbeans_update_resources b/ClientAccademico/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/ClientAccademico/build/classes/clientaccademico/ClientAccademico.class b/ClientAccademico/build/classes/clientaccademico/ClientAccademico.class new file mode 100644 index 0000000..2ed6ac0 Binary files /dev/null and b/ClientAccademico/build/classes/clientaccademico/ClientAccademico.class differ diff --git a/ClientAccademico/dist/ClientAccademico.jar b/ClientAccademico/dist/ClientAccademico.jar new file mode 100644 index 0000000..b3bc9f4 Binary files /dev/null and b/ClientAccademico/dist/ClientAccademico.jar differ diff --git a/ClientAccademico/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/ClientAccademico/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..3683de5 Binary files /dev/null and b/ClientAccademico/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/ClientAccademico/lib/USocket.jar b/ClientAccademico/lib/USocket.jar new file mode 100644 index 0000000..df2207c Binary files /dev/null and b/ClientAccademico/lib/USocket.jar differ diff --git a/ClientAccademico/lib/nblibraries.properties b/ClientAccademico/lib/nblibraries.properties new file mode 100644 index 0000000..b5bd56c --- /dev/null +++ b/ClientAccademico/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=3.0 diff --git a/ClientAccademico/manifest.mf b/ClientAccademico/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ClientAccademico/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ClientAccademico/nbproject/build-impl.xml b/ClientAccademico/nbproject/build-impl.xml new file mode 100644 index 0000000..b971945 --- /dev/null +++ b/ClientAccademico/nbproject/build-impl.xml @@ -0,0 +1,1796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ClientAccademico/nbproject/genfiles.properties b/ClientAccademico/nbproject/genfiles.properties new file mode 100644 index 0000000..4dd20b1 --- /dev/null +++ b/ClientAccademico/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=d2250e77 +build.xml.script.CRC32=20a369f1 +build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.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=d2250e77 +nbproject/build-impl.xml.script.CRC32=a55c77d5 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/ClientAccademico/nbproject/private/private.properties b/ClientAccademico/nbproject/private/private.properties new file mode 100644 index 0000000..ea67f5f --- /dev/null +++ b/ClientAccademico/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/boss/.netbeans/16/build.properties diff --git a/ClientAccademico/nbproject/private/private.xml b/ClientAccademico/nbproject/private/private.xml new file mode 100644 index 0000000..0e97f21 --- /dev/null +++ b/ClientAccademico/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/home/boss/Progetti/TestClientSocket/src/testclientsocket/TestClientSocket.java + + + diff --git a/ClientAccademico/nbproject/project.properties b/ClientAccademico/nbproject/project.properties new file mode 100644 index 0000000..174192c --- /dev/null +++ b/ClientAccademico/nbproject/project.properties @@ -0,0 +1,97 @@ +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.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ClientAccademico.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ClientAccademico +excludes= +file.reference.USocket.jar=lib/USocket.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.USocket.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=17 +javac.target=17 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ClientAccademico +main.class=clientaccademico.ClientAccademico +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.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ClientAccademico/nbproject/project.xml b/ClientAccademico/nbproject/project.xml new file mode 100644 index 0000000..48f36cf --- /dev/null +++ b/ClientAccademico/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + ClientAccademico + + + + + + + + + ./lib/nblibraries.properties + + + diff --git a/ClientAccademico/src/clientaccademico/ClientAccademico.java b/ClientAccademico/src/clientaccademico/ClientAccademico.java new file mode 100644 index 0000000..8b46631 --- /dev/null +++ b/ClientAccademico/src/clientaccademico/ClientAccademico.java @@ -0,0 +1,26 @@ +package clientaccademico; + +import com.mirimatcode.USocket; +import java.io.IOException; + +/** + * + * @author boss + */ +public class ClientAccademico { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + //String ip = "server.mirimatcode.eu"; + String ip = "192.168.2.187"; + try { + //USocket.writeString(ip, 5000, "Ciao mbarissimo"); + String stringa = USocket.writeAndListenString(ip, 5000, "Ciao mbare"); + System.out.println(stringa); + } catch (IOException ex) { + System.out.println("Problemi: " + ex.getMessage()); + } + } +} diff --git a/ClientPersistente/build.xml b/ClientPersistente/build.xml new file mode 100644 index 0000000..94d6316 --- /dev/null +++ b/ClientPersistente/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ClientPersistente. + + + diff --git a/ClientPersistente/build/classes/.netbeans_automatic_build b/ClientPersistente/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/ClientPersistente/build/classes/.netbeans_update_resources b/ClientPersistente/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/ClientPersistente/build/classes/clientpersistente/ClientPersistente.class b/ClientPersistente/build/classes/clientpersistente/ClientPersistente.class new file mode 100644 index 0000000..dba359c Binary files /dev/null and b/ClientPersistente/build/classes/clientpersistente/ClientPersistente.class differ diff --git a/ClientPersistente/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/ClientPersistente/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..3683de5 Binary files /dev/null and b/ClientPersistente/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/ClientPersistente/lib/USocket.jar b/ClientPersistente/lib/USocket.jar new file mode 100644 index 0000000..df2207c Binary files /dev/null and b/ClientPersistente/lib/USocket.jar differ diff --git a/ClientPersistente/lib/nblibraries.properties b/ClientPersistente/lib/nblibraries.properties new file mode 100644 index 0000000..b5bd56c --- /dev/null +++ b/ClientPersistente/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=3.0 diff --git a/ClientPersistente/manifest.mf b/ClientPersistente/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ClientPersistente/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ClientPersistente/nbproject/build-impl.xml b/ClientPersistente/nbproject/build-impl.xml new file mode 100644 index 0000000..e328457 --- /dev/null +++ b/ClientPersistente/nbproject/build-impl.xml @@ -0,0 +1,1796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ClientPersistente/nbproject/genfiles.properties b/ClientPersistente/nbproject/genfiles.properties new file mode 100644 index 0000000..241780c --- /dev/null +++ b/ClientPersistente/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=0a4857a7 +build.xml.script.CRC32=753a5039 +build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.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=0a4857a7 +nbproject/build-impl.xml.script.CRC32=63186a5c +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/ClientPersistente/nbproject/private/private.properties b/ClientPersistente/nbproject/private/private.properties new file mode 100644 index 0000000..ea67f5f --- /dev/null +++ b/ClientPersistente/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/boss/.netbeans/16/build.properties diff --git a/ClientPersistente/nbproject/project.properties b/ClientPersistente/nbproject/project.properties new file mode 100644 index 0000000..274cc6f --- /dev/null +++ b/ClientPersistente/nbproject/project.properties @@ -0,0 +1,95 @@ +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.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ClientPersistente.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ClientPersistente +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=17 +javac.target=17 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ClientPersistente +main.class=clientpersistente.ClientPersistente +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.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ClientPersistente/nbproject/project.xml b/ClientPersistente/nbproject/project.xml new file mode 100644 index 0000000..d49e9d4 --- /dev/null +++ b/ClientPersistente/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + ClientPersistente + + + + + + + + + ./lib/nblibraries.properties + + + diff --git a/ClientPersistente/src/clientpersistente/ClientPersistente.java b/ClientPersistente/src/clientpersistente/ClientPersistente.java new file mode 100644 index 0000000..a717a1b --- /dev/null +++ b/ClientPersistente/src/clientpersistente/ClientPersistente.java @@ -0,0 +1,46 @@ +package clientpersistente; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.Socket; +import java.net.UnknownHostException; + +public class ClientPersistente { + + public static void main(String[] args) { + + //String hostName = "192.168.2.187"; + String hostName = "server.mirimatcode.eu"; + int portNumber = 5000; + + try ( + Socket clientSocket = new Socket(hostName, portNumber); + PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); + BufferedReader in = new BufferedReader( + new InputStreamReader(clientSocket.getInputStream())); + ) { + BufferedReader stdIn = + new BufferedReader(new InputStreamReader(System.in)); + String fromServer; + String fromUser; + out.println("conncheck"); + + while ((fromServer = in.readLine()) != null) { + System.out.println("Server: " + fromServer); + + fromUser = stdIn.readLine(); + if (fromUser != null) { + out.println(fromUser); + if (fromUser.equals("ciao!")) + break; + } + } + } catch (UnknownHostException e) { + System.out.println(e.getMessage()); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/ServerAccademico/build.xml b/ServerAccademico/build.xml new file mode 100644 index 0000000..6d5b519 --- /dev/null +++ b/ServerAccademico/build.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + Builds, tests, and runs the project ServerAccademico. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ServerAccademico/build/built-jar.properties b/ServerAccademico/build/built-jar.properties new file mode 100644 index 0000000..1f370c5 --- /dev/null +++ b/ServerAccademico/build/built-jar.properties @@ -0,0 +1,4 @@ +#Wed, 01 Feb 2023 15:45:34 +0100 + + +/home/boss/Progetti/ServerAccademico= diff --git a/ServerAccademico/build/classes/serveraccademico/ServerAccademico.class b/ServerAccademico/build/classes/serveraccademico/ServerAccademico.class new file mode 100644 index 0000000..ade7d95 Binary files /dev/null and b/ServerAccademico/build/classes/serveraccademico/ServerAccademico.class differ diff --git a/ServerAccademico/dist/ServerAccademico.jar b/ServerAccademico/dist/ServerAccademico.jar new file mode 100644 index 0000000..f6e1df5 Binary files /dev/null and b/ServerAccademico/dist/ServerAccademico.jar differ diff --git a/ServerAccademico/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/ServerAccademico/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..3683de5 Binary files /dev/null and b/ServerAccademico/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/ServerAccademico/lib/USocket.jar b/ServerAccademico/lib/USocket.jar new file mode 100644 index 0000000..925c816 Binary files /dev/null and b/ServerAccademico/lib/USocket.jar differ diff --git a/ServerAccademico/lib/nblibraries.properties b/ServerAccademico/lib/nblibraries.properties new file mode 100644 index 0000000..b5bd56c --- /dev/null +++ b/ServerAccademico/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=3.0 diff --git a/ServerAccademico/manifest.mf b/ServerAccademico/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ServerAccademico/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ServerAccademico/nbproject/build-impl.xml b/ServerAccademico/nbproject/build-impl.xml new file mode 100644 index 0000000..352dd82 --- /dev/null +++ b/ServerAccademico/nbproject/build-impl.xml @@ -0,0 +1,1796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ServerAccademico/nbproject/genfiles.properties b/ServerAccademico/nbproject/genfiles.properties new file mode 100644 index 0000000..93001b8 --- /dev/null +++ b/ServerAccademico/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=0ee08b86 +build.xml.script.CRC32=e472c491 +build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.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=0ee08b86 +nbproject/build-impl.xml.script.CRC32=4bb9cc31 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/ServerAccademico/nbproject/private/private.properties b/ServerAccademico/nbproject/private/private.properties new file mode 100644 index 0000000..ea67f5f --- /dev/null +++ b/ServerAccademico/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/boss/.netbeans/16/build.properties diff --git a/ServerAccademico/nbproject/project.properties b/ServerAccademico/nbproject/project.properties new file mode 100644 index 0000000..12440bd --- /dev/null +++ b/ServerAccademico/nbproject/project.properties @@ -0,0 +1,97 @@ +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.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ServerAccademico.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ServerAccademico +excludes= +file.reference.USocket.jar=lib/USocket.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.USocket.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=17 +javac.target=17 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ServerAccademico +main.class=serveraccademico.ServerAccademico +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.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ServerAccademico/nbproject/project.xml b/ServerAccademico/nbproject/project.xml new file mode 100644 index 0000000..1207c32 --- /dev/null +++ b/ServerAccademico/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + ServerAccademico + + + + + + + + + ./lib/nblibraries.properties + + + diff --git a/ServerAccademico/src/serveraccademico/ServerAccademico.java b/ServerAccademico/src/serveraccademico/ServerAccademico.java new file mode 100644 index 0000000..02df15a --- /dev/null +++ b/ServerAccademico/src/serveraccademico/ServerAccademico.java @@ -0,0 +1,21 @@ +package serveraccademico; + +import com.mirimatcode.USocket; +import java.io.IOException; + +public class ServerAccademico { + + public static void main(String[] args) { + + while(true) { + String messaggio = ""; + try { + //messaggio = USocket.listenString(5000); + messaggio = USocket.listenAndReplyString(5000, "Ciao amico, ho ricevuto il tuo messaggio e ti saluto da Milano"); + System.out.println(messaggio); + } catch (IOException ex) { + System.out.println("Problemi: " + ex.getMessage()); + } + } + } +} diff --git a/ServerPersistente/build.xml b/ServerPersistente/build.xml new file mode 100644 index 0000000..2f3afa6 --- /dev/null +++ b/ServerPersistente/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ServerPersistente. + + + diff --git a/ServerPersistente/build/built-jar.properties b/ServerPersistente/build/built-jar.properties new file mode 100644 index 0000000..222ca72 --- /dev/null +++ b/ServerPersistente/build/built-jar.properties @@ -0,0 +1,4 @@ +#Wed, 01 Feb 2023 16:50:34 +0100 + + +/home/boss/Progetti/ServerPersistente= diff --git a/ServerPersistente/build/classes/serverpersistente/ServerPersistente.class b/ServerPersistente/build/classes/serverpersistente/ServerPersistente.class new file mode 100644 index 0000000..973fb53 Binary files /dev/null and b/ServerPersistente/build/classes/serverpersistente/ServerPersistente.class differ diff --git a/ServerPersistente/dist/README.TXT b/ServerPersistente/dist/README.TXT new file mode 100644 index 0000000..85e2107 --- /dev/null +++ b/ServerPersistente/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 "ServerPersistente.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/ServerPersistente/dist/ServerPersistente.jar b/ServerPersistente/dist/ServerPersistente.jar new file mode 100644 index 0000000..95a1878 Binary files /dev/null and b/ServerPersistente/dist/ServerPersistente.jar differ diff --git a/ServerPersistente/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/ServerPersistente/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..3683de5 Binary files /dev/null and b/ServerPersistente/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/ServerPersistente/lib/nblibraries.properties b/ServerPersistente/lib/nblibraries.properties new file mode 100644 index 0000000..b5bd56c --- /dev/null +++ b/ServerPersistente/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=3.0 diff --git a/ServerPersistente/manifest.mf b/ServerPersistente/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ServerPersistente/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ServerPersistente/nbproject/build-impl.xml b/ServerPersistente/nbproject/build-impl.xml new file mode 100644 index 0000000..eb99137 --- /dev/null +++ b/ServerPersistente/nbproject/build-impl.xml @@ -0,0 +1,1796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ServerPersistente/nbproject/genfiles.properties b/ServerPersistente/nbproject/genfiles.properties new file mode 100644 index 0000000..2f40da0 --- /dev/null +++ b/ServerPersistente/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c02e50a8 +build.xml.script.CRC32=104d1839 +build.xml.stylesheet.CRC32=f85dc8f2@1.105.0.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=c02e50a8 +nbproject/build-impl.xml.script.CRC32=c19a6bf3 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.105.0.48 diff --git a/ServerPersistente/nbproject/private/private.properties b/ServerPersistente/nbproject/private/private.properties new file mode 100644 index 0000000..ea67f5f --- /dev/null +++ b/ServerPersistente/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/boss/.netbeans/16/build.properties diff --git a/ServerPersistente/nbproject/project.properties b/ServerPersistente/nbproject/project.properties new file mode 100644 index 0000000..fa69769 --- /dev/null +++ b/ServerPersistente/nbproject/project.properties @@ -0,0 +1,95 @@ +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.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ServerPersistente.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ServerPersistente +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=17 +javac.target=17 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ServerPersistente +main.class=serverpersistente.ServerPersistente +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.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ServerPersistente/nbproject/project.xml b/ServerPersistente/nbproject/project.xml new file mode 100644 index 0000000..6055ddd --- /dev/null +++ b/ServerPersistente/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + ServerPersistente + + + + + + + + + ./lib/nblibraries.properties + + + diff --git a/ServerPersistente/src/serverpersistente/ServerPersistente.java b/ServerPersistente/src/serverpersistente/ServerPersistente.java new file mode 100644 index 0000000..e2a302b --- /dev/null +++ b/ServerPersistente/src/serverpersistente/ServerPersistente.java @@ -0,0 +1,50 @@ +package serverpersistente; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; + +public class ServerPersistente { + + public static void main(String[] args) { + + int portNumber = 5000; + + while(true) { + System.out.println("Avvio istanza server"); + try ( + ServerSocket serverSocket = new ServerSocket(portNumber, 100); + Socket clientSocket = serverSocket.accept(); + PrintWriter out = + new PrintWriter(clientSocket.getOutputStream(), true); + BufferedReader in = new BufferedReader( + new InputStreamReader(clientSocket.getInputStream())); + ) { + + String inputLine, outputLine; + + while ((inputLine = in.readLine()) != null) { + if(inputLine.compareTo("conncheck") == 0) { + System.out.println("Connessione in ingresso da: " + clientSocket.getInetAddress().getHostAddress()); + outputLine = "Connessione stabilita"; + } else { + System.out.println("Ricevuto: " + inputLine); + outputLine = "Ciao, mi hai appena scritto: " + inputLine; + } + + out.println(outputLine); + if (inputLine.equals("ciao!")) + { + System.out.println("Ricevuto codice di uscita bye bye"); + break; + } + } + } catch (IOException e) { + System.out.println(e.getMessage()); + } + } + } +} diff --git a/USocket/.gitignore b/USocket/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/USocket/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/USocket/build.xml b/USocket/build.xml new file mode 100644 index 0000000..abff3fe --- /dev/null +++ b/USocket/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project USocket. + + + diff --git a/USocket/dist/README.TXT b/USocket/dist/README.TXT new file mode 100644 index 0000000..934107e --- /dev/null +++ b/USocket/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 "USocket.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/USocket/dist/USocket.jar b/USocket/dist/USocket.jar new file mode 100644 index 0000000..df2207c Binary files /dev/null and b/USocket/dist/USocket.jar differ diff --git a/USocket/manifest.mf b/USocket/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/USocket/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/USocket/nbproject/build-impl.xml b/USocket/nbproject/build-impl.xml new file mode 100644 index 0000000..296c404 --- /dev/null +++ b/USocket/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/USocket/nbproject/genfiles.properties b/USocket/nbproject/genfiles.properties new file mode 100644 index 0000000..15c6061 --- /dev/null +++ b/USocket/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=73e21a97 +build.xml.script.CRC32=905bb893 +build.xml.stylesheet.CRC32=f85dc8f2@1.102.0.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=73e21a97 +nbproject/build-impl.xml.script.CRC32=04bab3ac +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.102.0.48 diff --git a/USocket/nbproject/private/private.properties b/USocket/nbproject/private/private.properties new file mode 100644 index 0000000..ea67f5f --- /dev/null +++ b/USocket/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/boss/.netbeans/16/build.properties diff --git a/USocket/nbproject/private/private.xml b/USocket/nbproject/private/private.xml new file mode 100644 index 0000000..17c9c05 --- /dev/null +++ b/USocket/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/home/boss/Progetti/USocket/src/com/mirimatcode/USocket.java + + + diff --git a/USocket/nbproject/project.properties b/USocket/nbproject/project.properties new file mode 100644 index 0000000..c7a0475 --- /dev/null +++ b/USocket/nbproject/project.properties @@ -0,0 +1,95 @@ +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.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/USocket.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/USocket +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=17 +javac.target=17 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=USocket +main.class=com.mirimatcode.USocket +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.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/USocket/nbproject/project.xml b/USocket/nbproject/project.xml new file mode 100644 index 0000000..ff0395c --- /dev/null +++ b/USocket/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + USocket + + + + + + + + + diff --git a/USocket/src/com/mirimatcode/USocket.java b/USocket/src/com/mirimatcode/USocket.java new file mode 100644 index 0000000..2999760 --- /dev/null +++ b/USocket/src/com/mirimatcode/USocket.java @@ -0,0 +1,112 @@ +package com.mirimatcode; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.UnknownHostException; + +public class USocket { + + /* + Lato server + */ + + /** + * Inizializza il Socket lato server e ritorna il Socket lato client una volta ricevuto + * @param porta porta di ascolto + * @return istanza del client ricevuto + * @throws IOException + */ + private static Socket initServer(int porta) throws IOException { + ServerSocket server = new ServerSocket(porta); + System.out.println("Server in ascolto"); + Socket client = server.accept(); + System.out.println("Ricevuto un pacchetto"); + server.close(); + return client; + } + + /** + * Mette il Socket lato server in ascolto e ritorna il messaggio una volta ricevuto + * @param porta porta di ascolto + * @return messaggio ricevuto + * @throws IOException + */ + public static String listenString(int porta) throws IOException { + Socket client = initServer(porta); + String messaggio = new BufferedReader(new InputStreamReader(client.getInputStream())).readLine(); + System.out.println("Ottenuto il messaggio"); + client.close(); + return messaggio; + } + + /** + * Mette il Socket lato server in ascolto, risponde con un messaggio al mittente e restituisce il messaggio ricevuto + * @param porta porta di ascolto + * @param risposta messaggio che si vuole trasmettere come risposta + * @return messaggio ricevuto + * @throws IOException + */ + public static String listenAndReplyString(int porta, String risposta) throws IOException { + Socket client = initServer(porta); + String messaggio = new BufferedReader(new InputStreamReader(client.getInputStream())).readLine(); + + String ip = client.getInetAddress().getHostAddress(); + client.close(); + System.out.println("Mi appresto a rispondere a " + ip); + + writeString(ip, porta, risposta); + + return messaggio; + } + + /* + Lato Client + */ + + /** + * Prepara un Socket lato client e trasmette il messaggio all'indirizzo IP specificato + * @param ip IP del destinatario del messaggio + * @param porta porta del destinatario + * @param messaggio messaggio che si vuole trasmettere + * @throws UnknownHostException + * @throws IOException + */ + public static void writeString(String ip, int porta, String messaggio) throws UnknownHostException, IOException { + Socket client = new Socket(ip, porta); + + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(client.getOutputStream())); + PrintWriter out = new PrintWriter(bw, true); + out.println(messaggio); + + out.close(); + client.close(); + } + + /** + * Prepara un Socket lato client, trasmette il messaggio all'indirizzo IP specificato e resta in ascolto di una risposta dal destinatario + * @param ip IP del destinatario del messaggio + * @param porta porta del destinatario + * @param messaggio messaggio che si vuole trasmettere + * @return messaggio ricevuto dal destinatario come risposta + * @throws UnknownHostException + * @throws IOException + */ + public static String writeAndListenString(String ip, int porta, String messaggio) throws UnknownHostException, IOException { + Socket client = new Socket(ip, porta); + + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(client.getOutputStream())); + PrintWriter out = new PrintWriter(bw, true); + out.println(messaggio); + String testo = listenString(porta); + out.close(); + client.close(); + + return testo; + } +} \ No newline at end of file