Menu

Using TCPStream correctly?

Help
Aatif Khan
2000-05-25
2000-06-12
  • Aatif Khan

    Aatif Khan - 2000-05-25

    Hi,
       I was testing out the TCPStream class, but I cannot get it to work.  The code is below

                InetHostAddress servingComputer(argv[1]);
               TCPStream clientStream(servingComputer, portnumber);

       This code always fails with the error SOCKET_CONNECT_REFUSED, even when the server is running.  I used gdb to trace through the code, and found out that the TCPStream constructor is receiving an InetHostAddress object with ipaddr = 0.  This screws up the host name lookup that takes place, and the connect fails because it doesn't know who to connect to.
       Am I doing something wrong?  I'm using the posix version on a Debian Linux (Potato) with g++ version 2.95.2.  Thanks for the help.

     
    • David Sugar

      David Sugar - 2000-06-04

      Do you get the same error if you do something like this:

      InetAddress addr = argv[1];

      ??

       
      • Aatif Khan

        Aatif Khan - 2000-06-05

        No.  It doesn't work with that.

        Is the way I'm trying to use it the correct way to use it, or is it something unusual?
        Thanks for the help.

         
    • Aatif Khan

      Aatif Khan - 2000-06-09

      Okay, I've tried my program on a Sun machine with gnu 2.95.2.  It works there because the reference to InetHostAddress doesn't become zero in the constructor of TCPStream.  I really can't think of a reason why this would screw up in Linux with the same version of the c++ compiler, but it does. 

      Any help would be appreciated.

       
      • David Sugar

        David Sugar - 2000-06-12

        I am going to build a test case for this.  You might want to look at my comments in
        regard to config.def as well, for it may be a compiler options issue.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.