Author: mkirby
Date: 2012-05-30 15:56:42 -0700 (Wed, 30 May 2012)
New Revision: 29402

Added:
   csplugins/trunk/soc/mkirby/Communication/.classpath
   csplugins/trunk/soc/mkirby/Communication/.project
   csplugins/trunk/soc/mkirby/Communication/src/
   csplugins/trunk/soc/mkirby/Communication/src/Test.java
Log:
mkirby: Got socket communication between R and Java working.

Added: csplugins/trunk/soc/mkirby/Communication/.classpath
===================================================================
--- csplugins/trunk/soc/mkirby/Communication/.classpath                         
(rev 0)
+++ csplugins/trunk/soc/mkirby/Communication/.classpath 2012-05-30 22:56:42 UTC 
(rev 29402)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>

Added: csplugins/trunk/soc/mkirby/Communication/.project
===================================================================
--- csplugins/trunk/soc/mkirby/Communication/.project                           
(rev 0)
+++ csplugins/trunk/soc/mkirby/Communication/.project   2012-05-30 22:56:42 UTC 
(rev 29402)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>Communication</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>

Added: csplugins/trunk/soc/mkirby/Communication/src/Test.java
===================================================================
--- csplugins/trunk/soc/mkirby/Communication/src/Test.java                      
        (rev 0)
+++ csplugins/trunk/soc/mkirby/Communication/src/Test.java      2012-05-30 
22:56:42 UTC (rev 29402)
@@ -0,0 +1,55 @@
+import java.net.*;
+import java.io.*;
+
+public class Test {
+       public static void main(String[] args) throws IOException {
+
+               boolean run = true;
+
+               // Try to connect to the port.
+               ServerSocket serverSocket = null;
+               try {
+                       serverSocket = new ServerSocket(4444);
+               } catch (IOException e) {
+                       System.err.println("Could not listen on port: 4444.");
+                       System.exit(1);
+               }
+
+               Socket clientSocket = null;
+               BufferedReader in = null;
+
+               // Listen for Clients.
+               while(run) {
+                       try {
+                               clientSocket = serverSocket.accept();
+                       } catch (IOException e) {
+                               System.err.println("Accept failed.");
+                               System.exit(1);
+                       }
+
+                       in = new BufferedReader(
+                                       new InputStreamReader(
+                                                       
clientSocket.getInputStream()));
+
+                       String line;
+                       while ((line = in.readLine()) != null) {
+                               System.out.println(line); 
+                               if ( line.endsWith("endRSend") ) {
+                                       System.out.println("Got data!");
+                                       break;
+                               }
+                               if ( line.equals("die") ) {
+                                       System.out.println("Got kill signal!");
+                                       run = false;
+                               }
+                       }
+               }
+
+               System.out.println("Terminating Server...");
+
+               // Clean up
+               in.close();
+               clientSocket.close();
+               serverSocket.close();
+       }
+}
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to