successfully open and close client socket after deploying cindy/TCPbeagle-bone/Parked
authorCindy Zhang <cindyzyx9@gmail.com>
Thu, 18 Feb 2016 01:17:43 +0000 (17:17 -0800)
committerCindy Zhang <cindyzyx9@gmail.com>
Thu, 18 Feb 2016 01:17:43 +0000 (17:17 -0800)
src/org/usfirst/frc/team3501/robot/Robot.java

index 8146a7afb252ec8cdd3ffd92c6556d9c03ce0f82..275eb452244028bedcae095945feb622c79cf79f 100644 (file)
@@ -3,7 +3,7 @@ package org.usfirst.frc.team3501.robot;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.net.Socket;
+import java.net.ServerSocket;
 
 import org.usfirst.frc.team3501.robot.Constants.Defense;
 import org.usfirst.frc.team3501.robot.subsystems.DefenseArm;
@@ -32,8 +32,7 @@ public class Robot extends IterativeRobot {
   SendableChooser positionOneDefense, positionTwoDefense, positionThreeDefense,
       positionFourDefense, positionFiveDefense;
 
-  Socket beagleBone;
-  Socket roboRIO;
+  ServerSocket roboRIO;
   DataInputStream beagleBoneInput;
   DataOutputStream beagleBoneOutput;
   DataInputStream roboRIOInput;
@@ -42,23 +41,15 @@ public class Robot extends IterativeRobot {
   @Override
   public void robotInit() {
     try {
-      beagleBone = new Socket("10.35.1.20", 1024);
-      roboRIO = new Socket("10.35.1.22", 1024);
-      // // create input stream for beagle bone to receive response from roboRIO
-      // beagleBoneInput = new DataInputStream(beagleBone.getInputStream());
-      // // create output stream to send information to the server socket
-      // beagleBoneOutput = new DataOutputStream(beagleBone.getOutputStream());
+      roboRIO = new ServerSocket(1024);
+      System.out.println("successfully opened");
       // // create input stream for beagle bone to receive response from roboRIO
       // roboRIOInput = new DataInputStream(roboRIO.getInputStream());
       // // create output stream to send information to the server socket
       // roboRIOOutput = new DataOutputStream(roboRIO.getOutputStream());
 
-    } catch (IOException e) {
-      System.out.println(e);
-    }
-
-    try {
-      beagleBoneOutput.writeBytes("hello!");
+      roboRIO.close();
+      System.out.println("successfully closed");
     } catch (IOException e) {
       System.out.println(e);
     }