View Single Post
  #1   Spotlight this post!  
Unread 03-03-2011, 11:42
Daniel Daniel is offline
Daniel Katanski
#0240
Team Role: Mentor
 
Join Date: Feb 2004
Location: Monroe, MI
Posts: 32
Daniel is on a distinguished road
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
Reply With Quote