Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.evolution.client;
- import java.net.*;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- import java.io.*;
- public class Client {
- private Socket client;
- private static PrintWriter out;
- private BufferedReader in;
- private static String ip = "108.60.194.19";
- private static int port = 213;
- private static String user;
- private static String pass;
- public static void main(String[] args) {
- LogInPage page = new LogInPage();
- page.Layout();
- Client client = new Client();
- client.startConnection();
- }
- //108.60.194.19
- public void startConnection() {
- try {
- client = new Socket(ip, port);
- out = new PrintWriter(client.getOutputStream(), true);
- in = new BufferedReader(new InputStreamReader(client.getInputStream()));
- out.println("Connection started from, " + client.getLocalAddress());
- out.flush();
- while (true) {
- String receive = in.readLine();
- System.out.println(receive);
- String send = null;
- @SuppressWarnings("resource")
- Scanner scan = new Scanner(System.in);
- if (scan.hasNext())
- send = scan.nextLine();
- if (send != null ) {
- out.println(send);
- out.flush();
- }
- }
- } catch (Exception e) {
- System.out.println(e);
- JOptionPane.showMessageDialog(null, e.toString(), "Connection-Error", JOptionPane.ERROR_MESSAGE);
- System.exit(0);
- }
- }
- public void testUserPass(String user, String pass) {
- Client.user = "DATA+USER" + user;
- Client.pass = "DATA+PASS" + pass;
- out.println(Client.user);
- out.println(Client.pass);
- }
- public void register(String user, String pass) {
- Client.user = "DATA+RUSER" + user;
- Client.pass = "DATA+RPASS" + pass;
- out.println(Client.user);
- out.println(Client.pass);
- }
- public void stopConnection() {
- try {
- in.close();
- out.close();
- client.close();
- }
- catch (Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement