Advertisement
Eternoseeker

gobackclient

Jun 7th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | Source Code | 0 0
  1. import java.io.DataInputStream;
  2. import java.io.DataOutputStream;
  3. import java.io.IOException;
  4. import java.net.Socket;
  5.  
  6. public class gobackclient {
  7.     public static void main(String[] args) throws IOException {
  8.         Socket s = new Socket("localhost", 3000);
  9.         DataInputStream din = new DataInputStream(s.getInputStream());
  10.         DataOutputStream dout = new DataOutputStream(s.getOutputStream());
  11.         int y = din.read();
  12.         System.out.println();
  13.         int[] arr = new int[y];
  14.         for (int i = 0; i < y; i++) {
  15.             arr[i] = din.read();
  16.             System.out.println("recieving frame: " + arr[i]);
  17.         }
  18.         arr[4] = -1;
  19.         int temp = 4;
  20.         for (int i = 0; i < y; i++) {
  21.             if (arr[i] == -1) {
  22.                 temp = i;
  23.                 System.out.println("eror in frame: " + arr[i]);
  24.             } else {
  25.                 System.out.println("reciving frame:" + arr[i]);
  26.             }
  27.         }
  28.         dout.write(temp);
  29.         for (int i = temp; i < arr.length; i++) {
  30.             arr[i] = din.read();
  31.             System.out.println("resent frame:" + i);
  32.         }
  33.         System.out.println("final frame");
  34.         System.out.println(arr[temp + 2]);
  35.         din.close();
  36.         s.close();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement