From: Cindy Zhang Date: Thu, 18 Feb 2016 01:17:43 +0000 (-0800) Subject: successfully open and close client socket after deploying X-Git-Url: http://challenge-bot.com/repos/?a=commitdiff_plain;h=refs%2Fheads%2Fcindy%2FTCPbeagle-bone%2FParked;p=3501%2Fstronghold-2016 successfully open and close client socket after deploying --- diff --git a/src/org/usfirst/frc/team3501/robot/Robot.java b/src/org/usfirst/frc/team3501/robot/Robot.java index 8146a7af..275eb452 100644 --- a/src/org/usfirst/frc/team3501/robot/Robot.java +++ b/src/org/usfirst/frc/team3501/robot/Robot.java @@ -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); }