diff --git a/GroundStation/README.md b/GroundStation/README.md index b2acb7e..f4f2650 100644 --- a/GroundStation/README.md +++ b/GroundStation/README.md @@ -3,6 +3,6 @@ Ground Station Acknowledgements: ----------------- -SmartScroller class found at: - [https://tips4java.wordpress.com/2013/03/03/smart-scrolling/](https://tips4java.wordpress.com/2013/03/03/smart-scrolling/) +SmartScroller class found at: + [https://tips4java.wordpress.com/2013/03/03/smart-scrolling/](https://tips4java.wordpress.com/2013/03/03/smart-scrolling/) source: [http://www.camick.com/java/source/SmartScroller.java](http://www.camick.com/java/source/SmartScroller.java) \ No newline at end of file diff --git a/TCPexample/Client.class b/TCPexample/Client.class new file mode 100644 index 0000000..21fd188 Binary files /dev/null and b/TCPexample/Client.class differ diff --git a/TCPexample/Client.java b/TCPexample/Client.java new file mode 100644 index 0000000..ded6630 --- /dev/null +++ b/TCPexample/Client.java @@ -0,0 +1,23 @@ +import java.lang.*; +import java.io.*; +import java.net.*; + +class Client { + public static void main(String args[]) { + try { + Socket skt = new Socket("192.168.42.1", 1234); + BufferedReader in = new BufferedReader(new + InputStreamReader(skt.getInputStream())); + System.out.print("Received string: '"); + + while (!in.ready()) {} + System.out.println(in.readLine()); // Read one line and output it + + System.out.print("'\n"); + in.close(); + } + catch(Exception e) { + System.out.print("Whoops! It didn't work!\n"); + } + } +} \ No newline at end of file diff --git a/TCPexample/Server.class b/TCPexample/Server.class new file mode 100644 index 0000000..f3ef10a Binary files /dev/null and b/TCPexample/Server.class differ diff --git a/TCPexample/Server.java b/TCPexample/Server.java new file mode 100644 index 0000000..fbd1eda --- /dev/null +++ b/TCPexample/Server.java @@ -0,0 +1,47 @@ +import java.lang.*; +import java.io.*; +import java.net.*; + +/** + * Echo server. if receives "DISCONNECT", will shut down server properly + */ +class Server { + 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"); + } + } +} \ No newline at end of file diff --git a/TCPexample/client b/TCPexample/client deleted file mode 100755 index 923b6aa..0000000 Binary files a/TCPexample/client and /dev/null differ diff --git a/TCPexample/server b/TCPexample/server deleted file mode 100755 index 6d3ff87..0000000 Binary files a/TCPexample/server and /dev/null differ diff --git a/TCPexample/server2.c b/TCPexample/server2.c index 833ea53..d7ab309 100644 --- a/TCPexample/server2.c +++ b/TCPexample/server2.c @@ -3,6 +3,7 @@ // From: // http://www.linuxhowtos.org/C_C++/socket.htm +// commented for reference #include #include