File tree Expand file tree Collapse file tree
src/ru/geekbrains/java2/lesson_06/Classwork Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package ru .geekbrains .java2 .lesson_06 .Classwork .client ;
2+
3+ public class Controller {
4+ }
Original file line number Diff line number Diff line change 1+ package ru .geekbrains .java2 .lesson_06 .Classwork .client ;
2+
3+ import javafx .application .Application ;
4+ import javafx .fxml .FXMLLoader ;
5+ import javafx .scene .Parent ;
6+ import javafx .scene .Scene ;
7+ import javafx .stage .Stage ;
8+
9+ public class Main extends Application {
10+
11+ @ Override
12+ public void start (Stage primaryStage ) throws Exception {
13+ Parent root = FXMLLoader .load (getClass ().getResource ("sample.fxml" ));
14+ primaryStage .setTitle ("Hello World" );
15+ primaryStage .setScene (new Scene (root , 300 , 275 ));
16+ primaryStage .show ();
17+ }
18+
19+
20+ public static void main (String [] args ) {
21+ launch (args );
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ <?import javafx .scene.layout.GridPane?>
2+ <GridPane fx : controller =" ru.geekbrains.java2.lesson_06.Classwork.client.Controller"
3+ xmlns : fx =" http://javafx.com/fxml" alignment =" center" hgap =" 10" vgap =" 10" >
4+ </GridPane >
Original file line number Diff line number Diff line change 1+ package ru .geekbrains .java2 .lesson_06 .Classwork .server ;
2+
3+ import java .io .IOException ;
4+ import java .io .PrintWriter ;
5+ import java .net .ServerSocket ;
6+ import java .net .Socket ;
7+ import java .util .Scanner ;
8+
9+ public class MainClass {
10+ public static void main (String [] args ) {
11+ try (ServerSocket serverSocket = new ServerSocket (8189 )) {
12+ System .out .println ("Server started..." );
13+ Socket socket = serverSocket .accept ();
14+ System .out .println ("Client connected." );
15+
16+ Scanner scanner = new Scanner (socket .getInputStream ());
17+ PrintWriter writer = new PrintWriter (socket .getOutputStream ());
18+
19+ String msg = "" ;
20+ while (!msg .equals ("/end" )) {
21+ msg = scanner .nextLine ();
22+ System .out .println ("Client said: " + msg );
23+ writer .println ("echo answer: " + msg );
24+ writer .flush ();
25+ }
26+ System .out .println ("Command for disconnect" );
27+ socket .close ();
28+ System .out .println ("Server stopped..." );
29+ } catch (IOException e ) {
30+ e .printStackTrace ();
31+ }
32+
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments