Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

socket problem using org.jdesktop.application.FrameView?

843790Mar 2 2009 — edited Apr 2 2009
I 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2009
Added on Mar 2 2009
2 comments
189 views