Anders Backman - 2002-05-01

Well I have a couple of issues now.
Im starting to guess that Im the first using .Net together with CommonC++?
At least with the later releases.

I have built version 2 of CommonC++ with VC++6 (as it doesnt work in .NET).
When I try to compile this sample application it throws a undefined exception inside the constructor of TCPStream (but it seems to be inside the IOSTREAM library somewhere!!)

The same application with the same library and the same version of CommonC++ works just fine with VC++6.

Sample code:

using ccgnu5d.lib
#include <cc++/socket.h>

class tcpStream : public ost::TCPStream {
public:
  /// Constructor, does not connect to any host (the Connect method will take care of that)
  tcpStream() : TCPStream() {
    setError(true);
    ost::setException(ost::Thread::throwObject);
  };

  /*! Constructor, connects to the specified remote host.
  \param host - Remote host to connect to
  \param port - Remote port to connect to
  \param size - Buffer size for the connection.
  */
  tcpStream(const ost::InetHostAddress &host, ost::tpport_t port, int size = 512) : ost::TCPStream( host, port, size) {
    setError(true);
    ost::setException(ost::Thread::throwObject);
  };
 
  /*! Connects to the remote host.
  \param host - Remote host to connect to
  \param port - Remote port to connect to
  \param size - Buffer size for the connection.
  */
  void connect(const ost::InetHostAddress &host, ost::tpport_t port, int size=512) {
    TCPStream::connect(host, port, size);
  };
};

int main()
{
    try {
        tcpStream *t = new tcpStream;
    }
    catch (ost::Socket *) {
        std::cerr << "Caught socket" << std::endl;
    }
    catch(std::exception &e) {
        std::cerr << e.what() << std::endl;
    }
    catch(...) {
        std::cerr << "Caught undefined exception" << std::endl;
    }
}