View Single Post
  #6   Spotlight this post!  
Unread 27-08-2014, 22:07
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: FRC Java TCP client

Quote:
Originally Posted by yash101 View Post
I am using a library to make socket programming extremely easy. However, the easiest to implement protocol that it supports is TCP. Also, I want a constant bi-directional data transfer. I basically want to have some request system, where the cRIO can request some data from the coprocessor, and vice-versa. This would also allow me to use the same socket server to send data to a UI, etc.

UDP is my last choice. For some basic path-planning, I will need to ensure that all the requests complete in a structured order!

I guess that if I can implement NetworkTables on the coprocessor, that would make things extremely simple! However, I don't think NetTables were built to be as portable as I want them to be!

What dont you understand about the Packet class?

write data to the PacketOutputStream and send it to the server..

found this in the SocketConnection class (which seems to be the well documented class around packets and sockets)

Code:
 SocketConnection sc = (SocketConnection)
 Connector.open("socket://host.com:79");
 sc.setSocketOption(SocketConnection.LINGER, 5);

 InputStream is = sc.openInputStream(); OutputStream os =
 sc.openOutputStream();

 os.write("\r\n".getBytes()); int ch = 0; while(ch != -1) { ch = is.read(); }

 is.close(); os.close(); sc.close();

Last edited by Arhowk : 27-08-2014 at 22:09.