20

In an app which I have programmed, I have a java.net.SocketException on a specific computer:

java.net.SocketException: Address family not supported by protocol family: connect

This specific computer runs Windows 7 32 Bit and is connected to the internet through Local Area Connection (Ethernet). The app runs correctly on other computers, with Windows 7 and Windows 8, connected through Local Area Connection or through Wi-Fi, so I am actually not sure that the problem is programmatic. I have tried to check the protocols of the Local Area Connection, but I didn't see any problems. Can someone please help me understand what is the problem? Why is this exception thrown?

Or B
  • 1,675
  • 5
  • 20
  • 41
  • Try any network packet monitoring software like Wireshark – prasanth May 04 '13 at 12:03
  • And what do I have to see there? – Or B May 04 '13 at 12:05
  • You are trying to connect to some port,right?? Check if the TCP packets were received on that port and what was the response received – prasanth May 04 '13 at 12:06
  • I am actually trying to work with HTTP, so it is port 80. – Or B May 04 '13 at 12:12
  • You monitor the traffic on 80 after you run your code – prasanth May 04 '13 at 12:14
  • Does my filter have to be "portmap.port == 80"? – Or B May 04 '13 at 12:20
  • yes. your filter should be – prasanth May 04 '13 at 12:22
  • It claims that: Header checksum: 0x0000 [incorrect, should be 0x15ff (may be caused by "IP checksum offload"?)] – Or B May 04 '13 at 12:44
  • http://ask.wireshark.org/questions/11682/checksum-errors-when-browsing-the-internet. Read this – prasanth May 04 '13 at 12:53
  • I don't understand much... I see here (http://wiki.wireshark.org/CaptureSetup/Offloading) the following instructions: In Windows, go to Control Panel->Network and Internet Connections->Network Connections, right click the connection to change and choose 'Properties'. Press the 'Configure...' button, choose the 'Advanced' tab to see or modify the "Offload Transmit TCP Checksum" and "Offload Receive TCP Checksum" values. I found this, but I don't known what are the wanted values for these settings. – Or B May 04 '13 at 13:33
  • OK, fixed it. It all seems OK but it still doesn't work. – Or B May 04 '13 at 14:22

6 Answers6

40

Try to check whether the spy program called "RelevantKnowledge" is installed. Its uninstallation helped me to solve the problem.

bronixx
  • 515
  • 5
  • 4
26

For me Java option -Djava.net.preferIPv4Stack=true did the trick

Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
mibutec
  • 2,929
  • 6
  • 27
  • 39
20
  1. Open command prompt (windows start button, type cmd in search)
  2. Click top left of command prompt, click properties, enable quick edit mode
  3. Copy: setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true

  4. Right click on command prompt, should paste

  5. Hit enter. That easy!
Jens
  • 67,715
  • 15
  • 98
  • 113
Satya Kaveti
  • 346
  • 2
  • 6
5

It may be a few things:

  • Anti-virus blocking the connection. If you have an anti-virus running on that computer, try disabling it for a test.
  • Java 7 trying to use IPv6 to connect: if you have Java 6 on the computers where it works and Java 7 where it fails, try disabling IPv6 in Java on the computer where it fails (instructions in this post)
Community
  • 1
  • 1
Christian Garbin
  • 2,512
  • 1
  • 23
  • 31
0

If you are using java 6, try to change to java 7. It works for me.

mikemaal
  • 317
  • 3
  • 6
0

Thanks this helped me :

Anti-virus blocking the connection. If you have an anti-virus running on that computer, try disabling it for a test.

Open command prompt (windows start button, type cmd in search) Click top left of command prompt, click properties, enable quick edit mode Copy: setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true Right click on command prompt, should paste Hit enter. That easy!