Something went wrong on our end
-
Brutzman, Don authoredBrutzman, Don authored
SasalaServer.java 1.85 KiB
//package Assignment01;
import java.io.*;
import java.net.*;
/**
*
* @author Jeremiah Sasala
*/
public class SasalaServer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try
{
ServerSocket serverSocket = new ServerSocket(2317);
while(true)
{
Socket clientConnection = serverSocket.accept();
OutputStream os = clientConnection.getOutputStream();
PrintStream ps = new PrintStream(os);
String entityName = "Ranger";
double xPos = Math.round(Math.random()*10);
double yPos = Math.round(Math.random()*10);
double zPos = Math.round(Math.random()*10);
ps.println("Entity position information");
ps.println("Name: " + entityName);
ps.println("X coordinate: " + xPos);
ps.println("Y coordinate: " + yPos);
ps.println("Z coordinate: " + zPos);
InetAddress localAddress = clientConnection.getLocalAddress();
InetAddress remoteAddress = clientConnection.getInetAddress();
int localPort = clientConnection.getLocalPort();
int remotePort = clientConnection.getPort();
System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " +
remoteAddress.toString() + ", " + remotePort + " ))");
ps.flush();
clientConnection.close();
}
}
catch(Exception e)
{
System.out.println("problem with networking: " + e);
}
}
}