I have a problem when trying to connect to a remote server.
SocketException: Invalid argument or cannot assign requested address
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
Here is how i create the socket
if (socket == null) {
socket = new Socket();
try {
socket.setReuseAddress(true);
socket.setTcpNoDelay(true);
} catch (SocketException ex) {
}
}
dstAddress = new InetSocketAddress(server, dstPort)开发者_Python百科;
srcAddress = new InetSocketAddress("localhost", srcPort);
socket.bind(srcAddress);
socket.connect(dstAddress);
Everything works fine on localhost.
http://comments.gmane.org/gmane.comp.finance.moneydance.general/5389
This sometimes occurs on other platforms - it used to occasionally occur on earlier versions of Mac OS X. The solution definitely lies outside of Moneydance since MD is requesting (through Java) to open a standard network connection and the system is saying that it is unable to do so.
The only solution I have found for this is to reboot your computer. If you are also running other software that uses a lot of network resources, try not running that for a while to see if it makes a difference.
Remove the bind() call. It is not required.
Try running your program with
-Djava.net.preferIPv4Stack=true
when connecting to the remote system.
精彩评论