Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
41 lines (35 loc) · 1.31 KB

File metadata and controls

41 lines (35 loc) · 1.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// CS 6421 - Simple Message Board Client in Java
// T. Wood
// Compile with: javac MsgClient
// Run with: java MsgClient
// @author Cong Sun
// @Gwid G48099998
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
public class MsgClient {
public static void main(String[] args) {
//System Argument should be [Host IP] [Port Number] [Message_Name] [Message_Content], check the count for the argument before try to run the program
if(args.length != 4){
System.out.println("argument number not corrent");
System.exit(-1);
}
//The First Argument is the Host IP
String host = args[0];
//The Second Argument is the Port Number
int portnum = Integer.parseInt(args[1]);
try{
//Create the socket object
Socket socket = new Socket(host,portnum);
//Create the PrintWriter object using the socket object
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
//Send [Message_Name] and a new line character
out.println(args[2]);
//Send [Message_Content]
out.println(args[3]);
}catch(Exception e){
System.out.println(e);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.