|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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! |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
||||
|
||||
|
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?"... |
|
#4
|
|||
|
|||
|
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? |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
|||
|
|||
|
@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?
|
|
#7
|
||||
|
||||
|
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... |
|
#8
|
|||
|
|||
|
I used an IP address and IPv6 is disabled (tested enabled to no positive result).
|
|
#9
|
|||
|
|||
|
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. |
|
#10
|
||||
|
||||
|
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
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Sockets connect slow from os x to win xp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|