From 2ae34c4c1825c891d159e36d78a92b2d83c441b5 Mon Sep 17 00:00:00 2001 From: michelefiori Date: Tue, 27 Feb 2024 16:08:55 +0100 Subject: [PATCH] Minor changes --- .../classes/java/main/iterative/Client.class | Bin 1661 -> 1932 bytes .../java/main/iterative/IterativeServer.class | Bin 1612 -> 1974 bytes .../java/main/multithread/MultiServer.class | Bin 846 -> 843 bytes .../java/main/multithread/ServerThread.class | Bin 1649 -> 1912 bytes src/main/java/iterative/Client.java | 14 ++++++----- src/main/java/iterative/IterativeServer.java | 23 +++++++++++------- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/build/classes/java/main/iterative/Client.class b/build/classes/java/main/iterative/Client.class index 4a61020a212f802f582fd9c3b955c937c146f7b5..c093a2380e617edb67de59d1229ddec35733b038 100644 GIT binary patch literal 1932 zcmaJ?>rxvx7(D{xHOm%)2@sQ(k_ITw1*hpPwR354aG^1fV&c?IZ(=R*;`Od)S9Z$- z^d0&d%?~^SGkt)*Q#<{%>&udO3Nw;c-_g-`J{`$_|9k!yfE-*MBN){XGcblY!<7@> z<{6ti$CwRBlSf?+NIS#D;db#x>=QQa53Dm)E3L#h|scA70& zlAhp=Fgy+e?`W7bFoi3Zb}F6vQZyJwEQevXID{dmV;o79;|#;KwV{x7S%-#M1)5`+ z8Gyp=b1M033{wHUBV?xJnsp%)SYQ~pU6b22*Oxlx@vh={k92l9f^v`)%Q?<%E1LHy ziC&gZx#W8-*%zw_ZW#CgH)*e9A)_&sd%B-|G(rLwv7+`}r5X-$zl2c==dorWjav+p zL>?(J!+eB05+G^~cMROcIzxiaqgu2a!Em()kIGAuEAAQi2=|Gv!RsRLIwqGdEm@FSD-DNUak_!OTp=)ZcF6dR{f(E8b7>&wa@4-9;PEP2gsk@W^%cuvLd zx+#|g!#y33@L0nW179lonci_kfDBqwEwdd}whaS$b&W|BqakTUly_1&F}$(luSlEpWPa>Uf&%Fc6ZufhY5 z7A9S$IQNd*l=zS^9g|Pl2*(UI4x~kwQ|1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gnSdW{2}ZOhz&Rvn~?HeXSK8EpaECH-h`a@+v_;i zfRYgZ(Rrk!m5^}6>Nq~{C(NC1z%x`wr$?^CTSr$NC;SdV7Y=dq2=;apK1{=ceZ0`A zw)#=h%yoOsACAC_HJqah4Wo+lc#8q+OtUTBgoKGXi%G%;=$xB`M#vN3#U7#P+QG)Bo6aOp2HR;gkD diff --git a/build/classes/java/main/iterative/IterativeServer.class b/build/classes/java/main/iterative/IterativeServer.class index 57adf30ba1c481adf952ff0828dcef4f72bbbcc8..78663cedfa10834eb996d64831d3cf24fff30432 100644 GIT binary patch literal 1974 zcmaJ?YgZdZ7=8u^f$ z=(2GY-3%ffM^zZDKRum4bFVvQE%XWu)unEbS*Y#os8AIjD_K;bg?@olQ@89_YPz69 zCCiaIi9rlm7`8EjltA}|&;nO?m5zA{3^xHVRZNjhq7P#R{xyM-bcFGOi7BZEMdQG1~HelbjF@Z@UC9b&6ByBLmtZ@yI-N0>=G)*SXlAg1P zpv~C0gIR$N5>(8)z7iN{My>ah)Vcm{wvD~#?{-fT@8UfR_iVh6xpUp$*fTK%+Nz#X z71PlbljB2tWZ`2QpO`eUVTl3@bn4(qrJ}-|tg1ey$lAD%Psw^&mQ*hA9jTwXdXKxR zmcFhEOf@Qs<7*HR7a0;hv++5;5JZ! zq15hy$}Bf`(G0V~Tu>xo-G;ZdT6tTA8*ydKxREI$i*M9a(X;^xR)m@yxXAh4P%B zteO=K$0~|l7lhDN(9$Wb%1VRNB|$c-7Jgv-vz(_IcE1qRLPssSrZ)o@+W3xf zA+ZZVpsPBRl~twpf?~D19ZnKOa13_LNbU+uoJDv2gP^1`(GW*dx+onTgogsZ#pkPG z7zJIDe$i9aiF^>0YL#qMW}Kmzp%Ee{J+Hu_%XYvOXc0-y z$1kbfsi2bk|Yqr%U5`)1TaV-1~f6?YlIXP3X_O~<-#i5_yMW; z0e7xkSXz@RV)+4efym5aoWEdN8e74zXF)T6OIl{>X_n? za7l#AIBDrR)d3S^FhGVh(cO~b$g5X69zVLS1j)t$RNwmxo5sKqx)uYH@aaR6pFj^hlTx} z{DF@926D(6*u<6y4-7mM%SU+3;Img`-x!1Iba(3MUVhtR@SZ~d^pcg}awtv@w-oDOB|H!KpM?x&^Hp;bP#NLk)|CI~-Szr7&!wbEUg<#N8b z!w?DD&t*a2WS{>Bjr`%`|5I_&DnsE-j)I@ClMNhBOyjg>kb9cY3LSBnFP-03AYOV$? z=TjW$RU9={(Hv82;B};>3L~cZR0ple8rpJIw2wG&IdHqU1CImms!tnraOVB*&(vOq zkQAohNQh~H2X1oXCl?o}GD_JLiHczWX+p9XuFFo4G&h#Wc^^!L3ghS}ib~`G3}T2p wl5)a_X^s&sh!8nVlfy7&5*?Jn2(_0HAqEFKA&8n@q)P)7;*QZ6r(D9s9|i}MI{*Lx diff --git a/build/classes/java/main/multithread/MultiServer.class b/build/classes/java/main/multithread/MultiServer.class index 6f33462f7cf9aca695339023b0e255fc6c2cfcdc..2f3f589b72262698d84e7e9d231b63d37572c05c 100644 GIT binary patch delta 446 zcmX|7%TB^T6g|_{4zxuJ2<4%IFXU-IK*P?3iMTN#VcBS-HHfBE;?9*W-Si{e$_5fi z`~Xe-6#W6C-l>T*nRDOg-nsAUn`*s&KfeIjfvrJ;%%K>VgBpIajH&K=121SZ$kkex zBNjfeTu}puCUSHJrMh413P-}gJQl)|R3e6C_{55u1`}zKw-~l1i`Y$M4Omba=7xde z2ON0@>*Bf}c)^+PIwy8V=tr(Ua{X~T$0`ik-p#Rl6?m6}AxD!TeeR4LyYCE6?f*#V zvGOg-$kF`b2&5l?p+K5Vk_k_J3O0_yMM4o4xI}3DC14pVWW`Y;GASy)hYW>$TN7j+e?ELlk|Bt*)EkIFr)$zu@<3T;g$Za3hJJ6+OgTHAGOrvGCuZ+`+rd8(*!T;3XG6t7^oUYoP z)9b5h7d^QxgcaK>T40v6LObRh~eq<;IXt@*^luKVMWM!Z-XB5@*iD40ZY8 tLl7aF6eC(hm?~%zB8XD-QYMBtZB7um!KUyk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tLUeG?(vL^Y-;nN4*5t2R}5?! z*cKRZe9x1Pa(%DrJ5Qt%7_EF~KedaVRK?EGs(|Hs8-agVZn)ATWV!=!{bDJ6^hgG> z{y^Gw84x+(hicdF0%uQw_iSbFgsK^;stTliNNC@h>$&Q-zc&8 zliT6pz6^Hl{RU6QD!yYk_Uypb`}k1MF>!j`=Fa^e9of`*@urM=>>dfsRu034a@AuB zs28g;cuLA>LyRC`u&Qk5$(G%WIHMZvu($&0AoOVSTGo&gRiVmCNY9DnLT|CstJqxemB4u}xi2_>qRIB<7HG!$fpGdV7 zx(#;Tz~>geK+VFJ_)43vEqtT5--21~qeu}iDn6&M$J*%!yB;0&hLCkXkSdWfwd5Ci z{qEI*#h;D`iq%U*tm^LNdaih8_31FVlhdgwdgMtD*=Kqb|MEmcP4=H7&N12zY&{)W zJ#2b}^_<6?iTaT*k$q=;_!lYvVY4ZNvVFw3KAUT=F0d5eoQyw98MlPY=kw*4xwFde zUTFRhxJs6OQj)*H#Q$BxDxGs0{*lBy-<%n~S81g5sB)FkV-|fmMA27prsg4ViM!|M zBNiwX+7JbCj8tJ!n-ipKC&<(aza!Pcxiqdz`0+ZZ^8^$W6FS6UeQjf_Kl zzSj8KrE!^@%NU@w_(B?d+Xm?!rlL{2i7{M7j@U_}$FYtH+{F}LBYKXp>x_6EZ%{dP z5uN8(uND|BP~bX;)ZYwE8CW!M1;W5mhOT84X?0q^GC0HU3iW4Oe5Ot?Qfp&$v4yb~ zawBF7<1I{V(QQ%uWGBrj=CZvM=c4srJI&=1vZT8}tE+gCs^;jwOvF5{^U7OPuk{yr lZI()}(j$l)qxTxcT#s|owO)yH(wP`YeIKiTi`x`#`~w;zg9QKp diff --git a/src/main/java/iterative/Client.java b/src/main/java/iterative/Client.java index d5f4ea4..ca1cfd0 100644 --- a/src/main/java/iterative/Client.java +++ b/src/main/java/iterative/Client.java @@ -8,7 +8,7 @@ class Client { String sentence; String modifiedSentence; - // input stream initialization (from user keyboard) + /* Initialize input stream (from user keyboard) */ BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); @@ -17,24 +17,26 @@ class Client { 6789: server service port number */ Socket clientSocket = new Socket("localhost", 6789); - // output stream towards socket initialization + /* Initialize output stream towards the socket */ DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); - // input stream from socket initialization + /* Initialize input stream from the socket */ BufferedReader inFromServer = new BufferedReader( new InputStreamReader(clientSocket.getInputStream())); - // read a line from the user + /* Read an input line */ sentence = inFromUser.readLine(); - // send the line to the server + /* Send the line to the server*/ outToServer.writeBytes(sentence + '\n'); - // read the response from the server + /* Read response from the server (string ending with '\n') */ modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); + + /* Close the socket */ clientSocket.close(); } } diff --git a/src/main/java/iterative/IterativeServer.java b/src/main/java/iterative/IterativeServer.java index afddbb9..ca2e7b8 100644 --- a/src/main/java/iterative/IterativeServer.java +++ b/src/main/java/iterative/IterativeServer.java @@ -8,34 +8,39 @@ class IterativeServer { String clientSentence; String capitalizedSentence; - // create a "listening socket" on the specified port + /* Create a "listening socket" on the specified port */ ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { - /* accept is a blocking call - once a new connection arrived, it creates - a new "established socket" */ + /* + * Call to accept function (blocking call). + * When a new connection arrives a new "established socket" is created + */ Socket connectionSocket = welcomeSocket.accept(); - // input stream from the socket initialization + /* Initialize input stream from the socket */ BufferedReader inFromClient = new BufferedReader( new InputStreamReader(connectionSocket.getInputStream())); - // output stream to the socket initialization + /* Initialize output stream towards the socket */ DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); - // read a line (that terminates with \n) from the client + /* Read a line (ending with '\n') from the client */ clientSentence = inFromClient.readLine(); - // wait for 10 seconds + /* simulate a processing time of 10 seconds*/ //Thread.sleep(10000); + /* Build the response */ capitalizedSentence = clientSentence.toUpperCase() + '\n'; - // send the response to the client + /* Send the response to the client */ outToClient.writeBytes(capitalizedSentence); + + /* Close the connection socket */ + connectionSocket.close(); } } } -- 2.18.1