Skip to content
Snippets Groups Projects
Commit 0dad084e authored by Justin Snell's avatar Justin Snell
Browse files

ConardSnellFinalProj - Start

parent 21b21d16
No related branches found
No related tags found
No related merge requests found
//package PositionClient;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
/**
*
* @author AJSNELL
*/
public class ConardSnellPositionReceiver {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
String hostName = args[0];
try (Socket clientSocket = new Socket(hostName, 8005);
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in))) {
String userInput;
out.println("unit id: 1\nunit pos: 11S MS 4859 9849");
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput);
System.out.println("from client: " + in.readLine());
}
} catch (UnknownHostException e) {
System.err.println("Don't know about host " + hostName);
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to " + hostName);
System.exit(1);
}
}
}
\ No newline at end of file
//package positionserver;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.PrintWriter;
public class ConardSnellPositionSender {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
try (ServerSocket serverSocket = new ServerSocket(8005);
Socket clientSocket = serverSocket.accept();
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));) {
System.out.println("Client connected on port 8005");
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println("Received message: " + inputLine + " from " + clientSocket.toString());
out.println(inputLine);
}
} catch (IOException e) {
System.out.println("Exception when trying to listen on port 8005");
}
}
}
\ No newline at end of file
## Final Course Projects 2018March
Create a dedicated subdirectory for each individual or team project.
Example: `SmithJones`
See the course syllabus for details on how to document your project.
compile.on.save=true
user.properties.file=C:\\Users\\don\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\Justin Snell\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
compile.on.save=true
user.properties.file=C:\\Users\\don\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\Justin Snell\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
compile.on.save=true
user.properties.file=C:\\Users\\don\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\Justin Snell\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment