socket problem using org.jdesktop.application.FrameView?
843790Mar 2 2009 — edited Apr 2 2009I am trying to connect to a piece of lab equipment using SCPI through sockets.
The example code provided by the manufacturer in java works and connects to the socket and gets a response (I put their code into netbeans and right click and click run, and it gives a response and connects to the socket).
The code that works is:
import java.io.*;
import java.net.*;
class ScpiSockTest {
public static void main(String[] args) {
String instrumentName = "128.29.167.155"; // Put instrument hostname here
try {
Socket t = new Socket(instrumentName, 5025); // Connect to instrument
...
But... I put VERY similar code in the same project in netbeans, which is called from selecting a menu item:
@Action
public void attemptConnection() {
SCPIReadWriter SCPIRWWorker;
Boolean socketOpenSuccessful = true;
String instrumentName = "128.29.167.155"; // Put instrument hostname here
try {
Socket t = new Socket(instrumentName, 5025); // Connect to instrument
// Set up a print output stream with automatic flushing
} catch (UnknownHostException e) {
System.err.println("Don't know about host: "+sigGenIPAddress+"."+e.toString());
//System.exit(1);
socketOpenSuccessful = false;
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: "+sigGenIPAddress+"."+e.toString());
socketOpenSuccessful = false;
//System.exit(1);
}
And I get this error:
Couldn't get I/O for the connection to: 128.29.167.155.java.net.SocketException: Malformed reply from SOCKS server
Does anyone know why I have no problem in a simple java program, but it doesn't work when I put the same code in a GUI?
The GUI uses the Netbeans:
/**
* Main method launching the application.
*/
public static void main(String[] args) {
launch(SpecialWaveformGeneratorApp.class, args);
}
I've since used Eclipse's VE and it uses:
/**
* @param args
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
multiWaveformApp application = new multiWaveformApp();
application.getJFrame().setVisible(true);
}
});
}
The socket connects just fine using Eclipse.
Regards,
Kurt
Edited by: peterskm on Apr 2, 2009 11:28 AM