Results 1 to 16 of 16
  1. #1
    Kapil Gupta is offline Member
    Join Date
    Jun 2008
    Posts
    9
    Rep Power
    0

    Default 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

  2. #2
    Kapil Gupta is offline Member
    Join Date
    Jun 2008
    Posts
    9
    Rep Power
    0

    Default

    No replies :(

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Normally connection refused found when the port is not listen. Did you check that your post can listen on Vista.

  4. #4
    Kapil Gupta is offline Member
    Join Date
    Jun 2008
    Posts
    9
    Rep Power
    0

    Default

    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

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by Kapil Gupta View Post
    Is this Operating system issue? or security issue or bad code written ?
    Hopefully I think this is an issue with the code. But I don't know to say anything about system issues. Because on Vista I didn't get any such issues.

  6. #6
    Kapil Gupta is offline Member
    Join Date
    Jun 2008
    Posts
    9
    Rep Power
    0

    Default

    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

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    How can you exactly it's security issue. Still there can be some bad coding, which have conflict with 64bits.

  8. #8
    Kapil Gupta is offline Member
    Join Date
    Jun 2008
    Posts
    9
    Rep Power
    0

    Default

    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

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    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.

  10. #10
    leaf is offline Member
    Join Date
    Jun 2008
    Posts
    1
    Rep Power
    0

    Lightbulb 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

  11. #11
    Join Date
    Jul 2008
    Posts
    3
    Rep Power
    0

    Default 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?

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    At the time of your client directing to your PC, that socket is listening through the specified port?

  13. #13
    Join Date
    Jul 2008
    Posts
    3
    Rep Power
    0

    Default

    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.

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    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.

  15. #15
    Join Date
    Jul 2008
    Posts
    3
    Rep Power
    0

    Default 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

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. how client know what kind of server
    By lemur in forum Networking
    Replies: 3
    Last Post: 05-31-2008, 07:11 AM
  2. client/server palindrom
    By Rgfirefly24 in forum New To Java
    Replies: 0
    Last Post: 04-28-2008, 02:19 AM
  3. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 09:18 AM
  4. Problems with client and server
    By Albert in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 06:07 AM
  5. Replies: 4
    Last Post: 06-05-2007, 01:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •