Advertisement
Guest User

Untitled

a guest
Nov 24th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. package com.evolution.client;
  2.  
  3. import java.net.*;
  4. import java.util.Scanner;
  5.  
  6. import javax.swing.JOptionPane;
  7.  
  8. import java.io.*;
  9. public class Client {
  10.  
  11. private Socket client;
  12. private static PrintWriter out;
  13. private BufferedReader in;
  14.  
  15. private static String ip = "108.60.194.19";
  16. private static int port = 213;
  17.  
  18. private static String user;
  19. private static String pass;
  20.  
  21. public static void main(String[] args) {
  22. LogInPage page = new LogInPage();
  23. page.Layout();
  24. Client client = new Client();
  25. client.startConnection();
  26. }
  27.  
  28. //108.60.194.19
  29. public void startConnection() {
  30. try {
  31. client = new Socket(ip, port);
  32. out = new PrintWriter(client.getOutputStream(), true);
  33. in = new BufferedReader(new InputStreamReader(client.getInputStream()));
  34. out.println("Connection started from, " + client.getLocalAddress());
  35. out.flush();
  36. while (true) {
  37. String receive = in.readLine();
  38. System.out.println(receive);
  39.  
  40. String send = null;
  41. @SuppressWarnings("resource")
  42. Scanner scan = new Scanner(System.in);
  43. if (scan.hasNext())
  44. send = scan.nextLine();
  45. if (send != null ) {
  46. out.println(send);
  47. out.flush();
  48. }
  49. }
  50. } catch (Exception e) {
  51. System.out.println(e);
  52. JOptionPane.showMessageDialog(null, e.toString(), "Connection-Error", JOptionPane.ERROR_MESSAGE);
  53. System.exit(0);
  54. }
  55. }
  56. public void testUserPass(String user, String pass) {
  57. Client.user = "DATA+USER" + user;
  58. Client.pass = "DATA+PASS" + pass;
  59.  
  60. out.println(Client.user);
  61. out.println(Client.pass);
  62. }
  63. public void register(String user, String pass) {
  64. Client.user = "DATA+RUSER" + user;
  65. Client.pass = "DATA+RPASS" + pass;
  66.  
  67. out.println(Client.user);
  68. out.println(Client.pass);
  69. }
  70. public void stopConnection() {
  71. try {
  72. in.close();
  73. out.close();
  74. client.close();
  75. }
  76. catch (Exception e) {
  77.  
  78. }
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement