SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 30th, 2008, 07:37 PM
Karelm Karelm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 57 m 53 sec
Reputation Power: 0
Sockets connect slow from os x to win xp

Hi,

I'm working on a client-server application. The following situations go well:
- Client & Server = 1 Windows XP machine
- Client & Server = 1 OS X machine
- Client = Windows XP machine, Server = OS X machine

But when I try to use the Windows machine as the server and connect from the OS X machine, I get a delay of 20 seconds before the connection is established.

I'm using basic code:
Code:
client:
  new Socket("x.x.x.x",yyyy);

server:
  ServerSocket s = new ServerSocket(yyyy);
  s.accept();


Anyone have an idea how this could happen and what I could do about it?

Thanks in advance!

Reply With Quote
  #2  
Old May 1st, 2008, 04:54 AM
tvc3mye's Avatar
tvc3mye tvc3mye is offline
Daniel Schildsky
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 539 tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 10 h 50 m 44 sec
Reputation Power: 148
Send a message via ICQ to tvc3mye Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye
JVM problem perhaps?

I am not sure if that's a hardware problem or a software one. But anyhow, we try to look at the software part.

What version of JVM are you running on your OS X machine? Perhaps it has something to do with a specific version of JVM running on your machine. Also, is it Sun's JVM or JVM distributed by any other vendors?

Also, perhaps you would like to use a profiler to find out which part of the program causes problem.
__________________
When the programming world turns decent, the real world will turn upside down.

Reply With Quote
  #3  
Old May 1st, 2008, 09:32 AM
mrider's Avatar
mrider mrider is offline
Even I don't know what I do
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2005
Location: Abducted by aliens
Posts: 1,253 mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 6 m 44 sec
Reputation Power: 561
Interestingly, I've found the same thing here at work. At home I use Linux exclusively. My job workstation is Windows XP. I've found that in several places, XP client to anything else (even another Windows box) is orders of magnitude slower than anything else.

I don't think it's Windows networking. I don't have any way to confirm this, but I suspect it's all the anti-malware software that is on the the computer. If I had the means to do so, I'd install Windows XP SP 2 on a clean machine, not install any firewall or A.V. software and test again. I suspect the differences would be dramatic.

I don't know if you have any way to test this theory, but food for thought at least.
__________________
A -> B: Ride.
The road to enlightenment is more fun on two wheels.

The recent fuel price increase has had an interesting side effect. Many of the people that used to always say to me "You shouldn't ride a motorcycle, they're dangerous" are now saying "So, what kind of mileage do you get?"...

Reply With Quote
  #4  
Old May 1st, 2008, 12:52 PM
Karelm Karelm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 57 m 53 sec
Reputation Power: 0
Thanks for the reactions.

At first I thought it was the XP machine causing the problem. However, I did a small test today from XP to XP (one of them running in vmware on the mac) and there where no connection problems. The only problem is thus when going from OS X (client) to XP (server).

I'm using "JRE System Library [JVM 1.5.0 (MacOS X Default)]" on the mac and "JRE System Library [jre1.5.0_14]" on xp.

Any ideas?

Reply With Quote
  #5  
Old May 1st, 2008, 03:40 PM
mrider's Avatar
mrider mrider is offline
Even I don't know what I do
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2005
Location: Abducted by aliens
Posts: 1,253 mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 6 m 44 sec
Reputation Power: 561
Well, just out of curiosity I created a quick Java server that simply accepts a connection and spews out what it receives - and ran that on my Windows box.
Code:
import java.io.*;
import java.net.*;

public class ReceiveTest {
    public static void main( String[] args )
    throws IOException {
        ServerSocket serverSocket = new ServerSocket(9000);

        Socket clientSocket = serverSocket.accept();

        BufferedReader in = new BufferedReader(
                new InputStreamReader(
                clientSocket.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) {
            System.out.println( inputLine );
        }
        in.close();
        clientSocket.close();
        serverSocket.close();
    }
}


Then I created a simple Java client that sends the text "This is a test", and ran it from a coworker's OS X box.
Code:
import java.io.*;
import java.net.*;

public class SendTest {
    public static void main(String[] args)
    throws IOException {
        Socket echoSocket = null;
        PrintWriter out = null;
        echoSocket = new Socket( "x.x.x.x", 9000 );
        out = new PrintWriter( echoSocket.getOutputStream(), true );
        out.print( "This is a test\r\n" );
        out.close();
        echoSocket.close();
    }
    
}


That code exactly as shown (except with a real IP Address) worked perfectly. This is about as minimal as it gets. If this is slow, then it's the machine. If it's not slow, then you need to start profiling your code.

Reply With Quote
  #6  
Old May 1st, 2008, 04:27 PM
Karelm Karelm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 57 m 53 sec
Reputation Power: 0
@mrider: Thanks for testing it out. I ran your script here and I got the same result as before: a 20-30 sec delay. So it's the machine huh, any suggestions?

Reply With Quote
  #7  
Old May 1st, 2008, 05:01 PM
mrider's Avatar
mrider mrider is offline
Even I don't know what I do
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2005
Location: Abducted by aliens
Posts: 1,253 mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level)mrider User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 6 m 44 sec
Reputation Power: 561
On the OS X side, did you use an IP address for the server, or a machine name? If you used a machine name, you might want to try an IP address to see if your DNS entries are borked.

If you used an address you might want to check to see if IP6 is turned off:
System Preferences -> Network -> Configure IPv6 -> off.

That's about all I have for you...

Reply With Quote
  #8  
Old May 2nd, 2008, 03:09 AM
Karelm Karelm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 57 m 53 sec
Reputation Power: 0
I used an IP address and IPv6 is disabled (tested enabled to no positive result).

Reply With Quote
  #9  
Old May 6th, 2008, 01:06 PM
Karelm Karelm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level)Karelm User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 57 m 53 sec
Reputation Power: 0
I found a solution (here):
Code:
socket = new Socket(ip,port);

replace by:

socket = new Socket(Proxy.NO_PROXY);
socket.connect(new InetSocketAddress(ip,port));

If you do need proxies, check the link, they offer alternative solutions.
Comments on this post
mrider agrees: Good to know!

Reply With Quote
  #10  
Old May 6th, 2008, 03:19 PM
tagmanadvance's Avatar
tagmanadvance tagmanadvance is offline
Kage Bunshin
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2005
Location: The Seven Seas Of Rhye
Posts: 767 tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level)tagmanadvance User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 4 h 37 m 57 sec
Reputation Power: 184
Send a message via AIM to tagmanadvance Send a message via Yahoo to tagmanadvance Send a message via XFire to tagmanadvance
I don't have this problem when connecting to my Mac with an app I made.
__________________
"Java makes impossible things possible, but makes easy things difficult." - Somebody

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Sockets connect slow from os x to win xp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway