minor updates

This commit is contained in:
Brendan Haines 2015-02-09 14:58:01 -07:00
parent a0fd3efb89
commit 98526900c7
3 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,51 @@
/**
*
*/
import java.lang.*;
import java.io.*;
import java.net.*;
/**
* Echo server. if receives "DISCONNECT", will shut down server properly
*/
class EchoServer {
public static void main(String args[]) {
ServerSocket srvr;
Socket skt;
BufferedReader in;
PrintWriter out;
try {
System.out.print( "Setting up server\n" );
srvr = new ServerSocket( 51717 );
skt = srvr.accept();
System.out.print( "Server has connected!\n" );
in = new BufferedReader( new InputStreamReader( skt.getInputStream() ) );
out = new PrintWriter( skt.getOutputStream(), true);
while( true ) {
System.out.print( "waiting for message...\n" );
while( !in.ready() ) {}
String rx = in.readLine();
System.out.print( "message received: " + rx + "\n" );
if( rx.equals( "DISCONNECT" ) ) {
System.out.print( "disconnecting\n" );
break;
}
System.out.print("Sending string: '" + rx + "'\n");
out.println( rx );
}
out.close();
in.close();
skt.close();
srvr.close();
}
catch(Exception e) {
System.out.print("Whoops! It didn't work!\n");
}
}
}

View File

@ -4,6 +4,7 @@ import java.net.*;
/**
* Echo server. if receives "DISCONNECT", will shut down server properly
* Used for testing GroundStation communications
*/
class Server {
public static void main(String args[]) {

Binary file not shown.