Subject Re: Linux Client Unable to complete network request problem
Author venushau
Thank you Roman.
The problem is solved.

I tried with a simple Socket testing program, which listens to the
opened ports for alive connection.

-----------------------
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;

public class TestSocketConnection
{

public static void main(String[] args) throws IOException
{
//Socket (host, port)
int port = 3050;
System.out.println("Port: " + port);
Socket s = new Socket("localhost", port);

// get input / output data streams out of the socket
DataInputStream in = new DataInputStream(s.getInputStream
());
DataOutputStream out = new DataOutputStream(
s.getOutputStream());
PrintStream out1 = new PrintStream( s.getOutputStream());

// read from input / write to output data streams:
String str = in.readLine();
out1.println ( "Echo: " + str + "\r");

// close the socket:
s.close();

}
}

-----------------------

The program shows a java.net.SocketException:
java.net.SocketException: Invalid argument or cannot assign
requested address

I found the solution from the following site, which tells that the
problem is from the combination of Fedora Core 3 /4 with JRE 1.4.2:
http://jon.shoberg.net/index.php?paged=5

Problem is solved by adding the parameter in the java command line:
-Djava.net.preferIPv4Stack=true


Thanks again for giving the suggestion.


----------------------
Ref from http://jon.shoberg.net/index.php?paged=5:
A tech note about why this is ….

"If IPv6 is available on the operating system the underlying native
socket will be an IPv6 socket. This allows Java(tm) applications to
connect to, and accept connections from, both IPv4 and IPv6 hosts."




--- In Firebird-Java@yahoogroups.com, "venushau" <venushau@...>
wrote:
>
> Thanks very much, Roman.
>
> I've use the same security policy file as in the Windows. For
> simplier start, I've made the policy file includes the following:
>
> grant {
> permission java.security.AllPermission;
> };
>
> I used the command:
> java -Djava.security.policy=policy -classpath .:../lib/jaybird-
full-
> 2.0.0.jar:../lib/log4j-core.jar TestFBConnection
>
> I'm not sure if the policy file can be read in this way, so I also
> tried using an absolute path to set the security policy. But this
> also doesn't help.
>
> Thanks for your comment.
> Let me try to make a socket connection program for testing.
>
>
> --- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
> <rrokytskyy@> wrote:
> >
> > > I wonder if this is a problem in the Linux environment
settings.
> > > Does anyone have an idea?
> >
> > Can you check the security policy of your JVM? It might block
> outgoing
> > connections for some reason.
> >
> > The most easy way to do this is to write small program that
opens
> a socket
> > connection to some specified port. Then you execute that class
> using the
> > same JVM.
> >
> > Roman
> >
>