-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSNAKE.java
82 lines (70 loc) · 1.95 KB
/
SNAKE.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* MAN EATER Cloud Technology v1.0 by Gary Wetter
*
* Thursday, May 1st, 2014
*
* This is SNAKE, MEG's slave to help protect men from Mary Mary v2.0 and her man eaters.
* Currently using TCP(Transmission Control Protocol).
*
*/
import java.io.*; import java.net.*; import java.util.*;
public class SNAKE
{
private static InetAddress host;
private static final int PORT = 1234;
public static void main(String[] args)
{
System.out.println("\n SNAKE v1.0\n Man Eater Guardian Server SLAVE - MECT by\n Gary Wetter \n Thursday, May 1st, 2014\n");
System.out.println("Please Standby...\n");
System.out.println("Penetrating MEG...\n");
try
{
host = InetAddress.getLocalHost();
}
catch(UnknownHostException uhEx)
{
System.out.println("Host ID not found!");
System.exit(1);
}
accessServer();
}
private static void accessServer()
{
Socket link = null; //Step 1. //Step 1.
try
{
link = new Socket(host,PORT);
Scanner input = new Scanner(link.getInputStream()); //Step 2.
PrintWriter output = new PrintWriter( link.getOutputStream(),true); //Step 2.
//Set up stream for keyboard entry...
Scanner userEntry = new Scanner(System.in);
String message, response;
do
{
System.out.print("Enter Command: ");
message = userEntry.nextLine();
output.println(message); //Step 3.
response = input.nextLine(); //Step 3.
System.out.println("\n MEG >> "+response);
}
while (!message.equals("KILL IT!"));
}
catch(IOException ioEx)
{
ioEx.printStackTrace();
}
finally
{
try
{
System.out.println("\n* Closing connection... *");
link.close(); //Step 4.
}
catch(IOException ioEx)
{
System.out.println("Unable to disconnect!");
System.exit(1);
}
}
}
}