LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-01-2005, 01:33 AM   #1
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
Java - sockets ok in Linux, not Win?


Hi guys,

This may be a bit OT, but I wonder if anybody else has ever encountered the following:

Sockets - creation works in the JVM on Linux as a browser applet, but fails quitely (no exceptions being thrown) on the Windows JVM.

Where can I start looking?
 
Old 09-01-2005, 02:06 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,491

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Which JVM ?
What kind of socket ?
 
Old 09-02-2005, 08:57 AM   #3
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Original Poster
Rep: Reputation: 87
The JVM versions are the official Sun versions for Linux and Windows:

Linux: j2re-1_4_2_05-linux-i586-rpm.bin
Windows: j2re-1_4_2_09-windows-i586-p.exe

The socket that is not being created is the one that must connect to port 21 (the FTP data port) on the target server. The FTP control port socket (port 20) apparently DOES get created by commons.net, since it is possible to pass commands and get responses on Windows JVM's (at least on the 3 different PC's I've tested on) but it appears to be impossible to establish a data socket to FTP port 21 on the Java JVM under Windows.

All permission restrictions have already been waived in an attempt to get the code working on Windows by placing an AllPermissions permission in the relevant java.policy file.

The code referred to runs perfectly under Linux...

Thanks for the response!
 
Old 09-02-2005, 11:43 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,491

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Turn off the firewall ... maybe.
 
Old 09-03-2005, 05:45 AM   #5
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Original Poster
Rep: Reputation: 87
Hi

No firewall running - systems all connect straight through a router. The Linux (working) system and the Windows (non-working) systems all go through this same router...

I'm assuming a bug in the windows JVM ...? I. e. I can do nothing about this?
 
Old 09-03-2005, 08:42 AM   #6
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Original Poster
Rep: Reputation: 87
I have done further testing on this and I have discovered that storeFile attempts to connect to the webserver the applet is running on, NOT the logged in FTP server as is logged in to when that instance of the FTPClient object that is having its storeFile method being called is started to be used.

On all XP machines, this is displayed in the Java console. Lines tagged J are JVM output, lines tagged P is output System.out.prinln'ed by my program:

J1: network: Connecting socket://polard.com:21 with proxy=DIRECT
J2: network: Connecting socket://polard.com:21 with proxy=DIRECT
P1: Connected for initial upload!
P2: Passive mode set
P2: Transferring...
P2: Starting upload now...
*J3: network: Connecting socket://www2a.your-server.co.za:50989 with proxy=DIRECT
Upload failed - storeFile returned false - socket?

The line marked with the asterisk is the error line.

Line J3 should be:

network: Connecting socket://polard.com:20 with proxy=DIRECT

to initate a data port connection (FTP on port 20) with the polard.com server, to start transferring the file. This is NOT what happens - why does it connect to my webserver,

network: Connecting socket://www2a.your-server.co.za:50989 with proxy=DIRECT

instead of polard.com:20? With a random port number? The :50989 changes from run to run.

On the Linux JVM, it looks and works exactly right:

J1: network: Connecting socket://polard.com:21 with proxy=DIRECT
J2: network: Connecting socket://polard.com:21 with proxy=DIRECT
P1: Connected for initial upload!
P2: Passive mode set
P2: Transferring...
P2: Starting upload now...
*J3: network: Connecting socket://polard.com:20 with proxy=DIRECT

So the apparent bug is that on Windows JVMs the commons.net FTP module "forgets" the server it is connected to, trying instead to open a socket to the host the applet is running on, instead of the FTP server connected to and logged in to with the FTPClient object's instances of connect() and login().

Any ideas at all at how to fix this?
 
Old 09-05-2005, 01:33 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,491

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Well, you have dig deep enough to figure-out where the problem lies, not into Sun's JVM but in Apache jakarta commons.net package.

You can either fix it yourself, as it is open source, or report the issue to Jakarta people.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java - networking - why working in Lin and not Win? rylan76 Programming 0 09-02-2005 03:55 AM
Java cannot create sockets in redhat fc4. ramman Linux - Networking 8 07-26-2005 10:32 AM
Linux Sockets JanusPaul Programming 5 11-14-2004 11:44 AM
My instructions are for Linux, but I work in Win...what is the win equialent of (~)? michaelton Linux - Newbie 2 05-21-2004 11:15 AM
Linux sockets linlai Programming 2 07-16-2002 02:51 PM


All times are GMT -5. The time now is 01:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration