socket opening error : Invalid argument: create with JDK 1.6u37

时间:2016-04-04 16:37:19

标签: java windows sockets java-native-interface socketexception

I have the following issue. I have a java .jar who is used by a cpp program (visual studio) and a java application.

I use a connect method to connect to a target. With the java library and the cpp program the connect failed with the following issue :

java.net.SocketException: Invalid argument: create

    at java.net.Socket.createImpl(Socket.java:397)

    at java.net.Socket.connect(Socket.java:527)

    at com.alcatel.microwave.net.tcp.client.TcpClient.doConnectWithTimeout(TcpClient.java:322)

   [...]

On the same computer, the connection is successful with the java application who use the same library (so the same connect function).

Some precisions :

  • the code is located and run on Clearcase view

  • there is computer who run the code without issue

  • I tried to add the following option : options[5].optionString = "-Djava.net.preferIPv4Stack=true";

  • I access the JVM with JNI when I have the issue.

Thanks in advance

Here a little example :

try
{

Socket connectionSocket = new Socket();   
connectionSocket.connect( serverAddress, timeout );

}

catch( Exception e )
{
    synchronized( this )
    {
        connectionSocket = null;
    }

    if( logger.isDebugEnabled() )
    {     
        e.printStackTrace();
        logger.debug( e.getMessage() );
    }   
}

0 个答案:

没有答案