Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package client2;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.net.Socket;
- import java.net.UnknownHostException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JOptionPane;
- public class Transfers {
- public int port = 1223;
- //public String Ip = LoginForm.IP;
- //public String ip = null;
- public static Socket login = null;
- public static Socket sock = null;
- public static PrintWriter outStream = null;
- private static BufferedReader inStream = null;
- private static boolean ON = false;
- public static String authorize = null;
- public static boolean connected = true;
- public static void transfers(String IP, int port, String content) throws UnknownHostException, IOException {
- try {
- login = new Socket(IP, port);
- //System.out.println("Connected for streaming");
- outStream = new PrintWriter(login.getOutputStream(), true);
- outStream.println(content);
- } catch (UnknownHostException ex) {
- Logger.getLogger(Transfers.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(Transfers.class.getName()).log(Level.SEVERE, null, ex);
- login.close();
- }
- }
- public static String[] recieveArray(String IP) throws UnknownHostException, IOException {
- String[] farray = null;
- sock = new Socket(IP, 1224);
- inStream = new BufferedReader(new InputStreamReader(sock.getInputStream()));
- String count = inStream.readLine();
- int counter = Integer.parseInt(count);
- System.out.println("counter");
- for (int i = 0; i < counter; i++) {
- inStream = new BufferedReader(new InputStreamReader(sock.getInputStream()));
- farray[i] = inStream.readLine();
- System.out.println(farray[i]);
- }
- return farray;
- }
- }
- ----------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement