Results 1 to 16 of 16
- 06-05-2008, 03:18 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 9
- Rep Power
- 0
Server not able to connect client
Hi All,
I have a C++ application which runs a server on some specific port (say 5001).I have also a java client which will connect to this server and can do some predefine tasks.
In windows XP,
I am able to run java client which do
Runtime.getRuntime().exec(cmd); // my c++ application
and create sockect and is connected to the server.like
do {
scomm = new Socket("Computer-Name", port);
} while (!scomm.isConnected());
everything works fine in windows XP.
But the same thing fails in 64 bit operating system Vista, Intel(R) Core(TM) 2 CPU.
Throwing error java.net.ConnectException.
Stack trace doenot yield much info.
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(UnKnown Source)
at java.net.PlainSocketImpl.connectToAddress(UnKnown Source)
at java.net.PlainSocketImpl.connect(UnKnown Source)
at java.net.SocksSocketImpl.connect(UnKnown Source)
at java.net.Socket.connect(UnKnown Source)
at java.net.Socket.connect(UnKnown Source)
at java.net.Socket.<init>(UnKnown Source)
at java.net.Socket.<init>(UnKnown Source)
If I ran server on vista and the client ( this time I am not calling exec) on XP or vice versa, socket is able to establish connection.
So the problem lies only when both client and server runs on Vista. Can somebody plz help ?
Thanks in anticipation
Kapil
- 06-09-2008, 02:07 PM #2
Member
- Join Date
- Jun 2008
- Posts
- 9
- Rep Power
- 0
No replies :(
- 06-09-2008, 02:20 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Normally connection refused found when the port is not listen. Did you check that your post can listen on Vista.
- 06-09-2008, 02:35 PM #4
Member
- Join Date
- Jun 2008
- Posts
- 9
- Rep Power
- 0
Hi Eranga,
I have tried with different ports also. One point to notice here is :
If I ran server on vista and the client ( this time I am not calling exec) on XP or vice versa, socket is able to establish connection. So the problem lies only when both client and server runs on Vista.
Is this Operating system issue? or security issue or bad code written ?
Thanks
Kapil
- 06-09-2008, 03:01 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-10-2008, 12:43 PM #6
Member
- Join Date
- Jun 2008
- Posts
- 9
- Rep Power
- 0
Hi,
I think this issue is something related to Vista 64bit security. As the same code is working fine in 64 bit Win XP machine, 32 bit Vista machine and 32 bit XP machine.
Regards,
Kapil
- 06-11-2008, 03:34 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
How can you exactly it's security issue. Still there can be some bad coding, which have conflict with 64bits.
- 06-17-2008, 01:15 PM #8
Member
- Join Date
- Jun 2008
- Posts
- 9
- Rep Power
- 0
Hi Eranga,
I think you are right, I noticed that if I ran my jar file from command prompt with command:
java -jar -cp . Filename.jar
Socket is able to connect to server. But if I double click on the jar file, it is not able to connect.
I am spawning a new process to create server by
p = Runtime.getRuntime().exec(cmd,null,new File(execPath));
and connecting to it by
try {
InetAddress address = InetAddress.getLocalHost();
do {
scomm = new Socket(address, port);
} while (!scomm.isConnected());
} catch ......
Is this problem specific to jar file ?
Waiting for reply,
Kapil
- 06-18-2008, 04:01 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I don't think this is specific to jar file. Did you get any warning/error message when you double click on the jar file, I guess you have. Basically it can be conflict with class path.
- 06-18-2008, 09:17 PM #10
Member
- Join Date
- Jun 2008
- Posts
- 1
- Rep Power
- 0
Socket Programming
In the java socket programming, is it possible to identify that the current connect is establised by a telnet session and not through an application.
Socket s = m_sock.accept();
SK
- 07-17-2008, 08:18 AM #11
Member
- Join Date
- Jul 2008
- Posts
- 3
- Rep Power
- 0
Similar Anomalies
I'm seeing similar odd behavior.
I have a simple server built in visual basic, listening to port 5555. In VB, it's
Dim Listener As New UdpClient(5555).
I have simple client built in Java to communicate to the server. It cannot seem to communicate to the server on my local machine. I'm receiving an IO Exception. This is java code that I've used successfully on Win 2000 OS.
If I point the client to any other IP address that is not on my machine, it is fine.
What's odd, is that I've also used a simple VB client, which was able to communicate to the server on my local machine locally successfully.
While I won't rule out a programming issue, I'm suspecting something else. I'm highly suspicious that it's some sort of security setup. I've turned off the firewall and security, but that did not fix anything.
I've tried having the client communicate to the server on localhost as well as 127.0.0.1, and it doesn't work. It behaves as if it can't see the local machine.
In my searches, I stumbled on a site discussing 'netsh interface tcp set global autotuning=disabled', but I was unable to run it on my machine; I received a response "Set global command failed on IPv4 The requested operation requires elevation."
netstat -a reveal the port listening at 0.0.0.0:5555.
Any thoughts or comments?
- 07-18-2008, 05:53 AM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
At the time of your client directing to your PC, that socket is listening through the specified port?
- 07-18-2008, 06:53 AM #13
Member
- Join Date
- Jul 2008
- Posts
- 3
- Rep Power
- 0
yes. Both server and client are set to the same port, in this case 5555. I've done additional searches today and have found several instances of folks having client/server apps in java unable to communicate on the same machine utilizing Vista. Unfortunately, all were left unanswered.
I continue to suspect it's some sort of Vista security item. I attempted to make adjustments to firewall settings, but had no success.
Any insight would be appreciated.
- 07-18-2008, 08:03 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can't you test with port 5001. Because using that you can avoid all firewall and stuff.
By the way, what are instance that you found effect to communicate in vista.
- 07-20-2008, 03:20 AM #15
Member
- Join Date
- Jul 2008
- Posts
- 3
- Rep Power
- 0
Fundamental Error
Alright, I figured out the problem. The issue had nothing to do with firewalls or Windows Vista.
My problem was a fundamental network miscommunication. The server I had was listening for a UDP packet. The client was sending TCP.
I wrote a UDP client and problem solved!
Once I figured that out, I got things where I wanted them to be, which was a TCP client/server.
Thanks for the assistance!
CK
- 07-22-2008, 04:09 AM #16
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Nice, if you solve the problem, it's better to make the thread solved. :)
Similar Threads
-
how client know what kind of server
By lemur in forum NetworkingReplies: 3Last Post: 05-31-2008, 07:11 AM -
client/server palindrom
By Rgfirefly24 in forum New To JavaReplies: 0Last Post: 04-28-2008, 02:19 AM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM -
Problems with client and server
By Albert in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 06:07 AM -
without restarting the websphere server i need to connect a newly created database
By satya in forum Enterprise JavaBeans (EJB)Replies: 4Last Post: 06-05-2007, 01:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks