|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help opening a socket to send data to Classmate running putty.
Attention coding wizards:
My goal is to send diagnostic text to the Classmate to be displayed using putty as a custom/flexible diagnostic display. Here is my code: import javax.microedition.io.SocketConnection; import javax.microedition.io.Connector; import java.io.OutputStream; import java.io.IOException; private SocketConnection socket ; // Socket to Classmate private OutputStream outputStream; try { socket = (SocketConnection) Connector.open("telnet://10.36.38.6:23"); socket.setSocketOption(SocketConnection.LINGER, 5); outputStream = socket.openOutputStream(); System.out.println("Diagnostic socket open.\r\n"); outputStream.write("Goodbye World!\r\n".getBytes()); outputStream.close(); } catch (IOException e) { System.out.println("Error opening diagnostic socket: " + e.getMessage() + "\r\n"); } This code gets an error stating "Telnet protocol is not available" (or something similar). I will try another socket number tonight. But does anyone have any suggestions how to open a socket or stream to send that to the classmate. Dan |
|
#2
|
|||
|
|||
|
Re: Need help opening a socket to send data to Classmate running putty.
According to Team Update #5 there are 5 ports available: TCP 1180, UDP 1130, UDP 1140, HTTP 80 and HTTP 443.
FIRST must have disabled all other ports. |
|
#3
|
||||
|
||||
|
Re: Need help opening a socket to send data to Classmate running putty.
I don't think Putty can be set to listen on a port as a telnet server. Correct me if I'm wrong. Usually putty is used as a client to connect to a listening "server'. You may need to call 'listen' (specifying an availabe port) and 'accept' in your CRIO code and then Putty on the classmate can connect to it. Exaclty how to do that in java is beyond what I can look up right now.
|
|
#4
|
|||
|
|||
|
Re: Need help opening a socket to send data to Classmate running putty.
I'll leave this here:
http://code.google.com/p/grtframewor...2Fn etworking you should find examples for what you're looking for, as well as other networking setups. This code has been tested, so you should be good to go. |
|
#5
|
||||
|
||||
|
Re: Need help opening a socket to send data to Classmate running putty.
You need to use the "socket:" or "serversocket:" protocols instead of "telnet:" when you create your connection. And definitely check out spartango's example code.
|
|
#6
|
|||
|
|||
|
Re: Need help opening a socket to send data to Classmate running putty.
I tryied spartango's link, but got page not found.
Spartango, can you please paste the code into this thread or create an attachment? |
|
#7
|
||||
|
||||
|
Re: Need help opening a socket to send data to Classmate running putty.
You can find more information and example code on networking and file i/o in these articles:
http://developers.sun.com/mobility/midp/articles/genericframework/ http://developers.sun.com/mobility/midp/articles/midp2network/ |
|
#8
|
|||
|
|||
|
Re: Need help opening a socket to send data to Classmate running putty.
spartango and derek, I've tried to test this sample but can not find definitions for the SocketListener and SocketEvent objects.
Has this code every been tested/run in our FIRST configuration? I would still like to get this working. As a interm fix I am getting a Serial RS232 to USB converter and will use putty listening to COM1. |
|
#9
|
||||
|
||||
|
Re: Need help opening a socket to send data to Classmate running putty.
Hi, those classes are also in spartango's code:
http://code.google.com/p/grtframewor...tListener.java http://code.google.com/p/grtframewor...cketEvent.java |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|