-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnector
More file actions
56 lines (40 loc) · 1.17 KB
/
connector
File metadata and controls
56 lines (40 loc) · 1.17 KB
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
/*
Check randomProgams/chatMain for the info of this script
*/
package sockets;
import java.net.*;
import java.io.*;
import java.util.Scanner;
public class connector
{
ServerSocket server;
Socket socket;
int port = 9000;
DataOutputStream output;
BufferedReader input;
String JVMmessage, TELNETmessage;
Scanner read;
public void start()
{
try{
server = new ServerSocket(port);
socket = new Socket();
socket = server.accept();
input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
read = new Scanner(System.in);
output = new DataOutputStream(socket.getOutputStream());
output.writeUTF("type stop if you want to close the connection");
output.writeUTF("\n");
do{
output.writeUTF("Telnet: ");
TELNETmessage = input.readLine();
System.out.println("Telnet: "+TELNETmessage);
System.out.print("Java: ");
JVMmessage = read.nextLine();
output.writeUTF("Java: "+JVMmessage);
output.writeUTF("\n");
}while(!(TELNETmessage.equals("stop")) && !(JVMmessage.equals("stop")));
socket.close();
}catch(Exception e){};
}
}