Deal with comstack that cannot be created
[yazpp-moved-to-github.git] / src / yaz-pdu-assoc.cpp
index a7fc349..2b73275 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2001, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-pdu-assoc.cpp,v 1.30 2003-10-01 13:13:51 adam Exp $
+ * $Id: yaz-pdu-assoc.cpp,v 1.32 2003-10-10 10:50:37 adam Exp $
  */
 
 #include <assert.h>
@@ -387,7 +387,7 @@ int Yaz_PDU_Assoc::send_PDU(const char *buf, int len)
 
 COMSTACK Yaz_PDU_Assoc::comstack(const char *type_and_host, void **vp)
 {
-    return cs_create_host(type_and_host, 0, vp);
+    return cs_create_host(type_and_host, 2, vp);
 }
 
 void Yaz_PDU_Assoc::listen(IYaz_PDU_Observer *observer,
@@ -428,6 +428,11 @@ void Yaz_PDU_Assoc::connect(IYaz_PDU_Observer *observer,
     m_PDU_Observer = observer;
     void *ap;
     m_cs = comstack(addr, &ap);
+    if (!m_cs)
+    {
+        m_PDU_Observer->failNotify();
+       return;
+    }
     int res = cs_connect (m_cs, ap);
     yaz_log (m_log, "Yaz_PDU_Assoc::connect fd=%d res=%d", cs_fileno(m_cs),
             res);