aboutsummaryrefslogtreecommitdiff
path: root/CS2452/assign5/src/Client.java
blob: 9d7cb19b6fa85c19e79d3a5c60f076090c4e9899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.net.*;
import java.io.*;

class Client
{
	public static void main(String[] args)
	{
		try
		{
			byte b = 0;
			int cnt = 0;
			Socket s = new Socket(args[0], Integer.parseInt(args[1]));
			DataInputStream di = new DataInputStream(s.getInputStream());
			while (true)
			{
				b = di.readByte();
				System.out.printf("%d - %d\t%x\t%c\n", ++cnt, b, b, b);
				if ((cnt % (1024 * 1024)) == 0)
				{
					System.out.println("------MILLION------\n\n");
					cnt = 0;
					Thread.sleep(1000);
					di.close();
					return;
				}
			}
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}