SHARE
TWEET

Untitled

a guest Feb 21st, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.net.*;
  3. public class MyClient{
  4.     public MyClient(String ip, int port){
  5.         String message;
  6.         try{
  7.             Socket me = new Socket(ip, port);
  8.             System.out.println("Server connected");
  9.             DataInputStream dis = new DataInputStream(me.getInputStream());
  10.             DataOutputStream dos = new DataOutputStream(me.getOutputStream());
  11.  
  12.             message = (String) dis.readUTF();
  13.             System.out.println("Message received : " + message);
  14.             dos.writeUTF("GG");
  15.             me.close();
  16.             System.out.println("Closed");
  17.         }catch(Exception e){
  18.             System.out.println(e);
  19.         }
  20.     }
  21.     public static void main(String[] args){
  22.         MyClient server = new MyClient("localhost",10074);
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top