1 // $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.4 2002-11-30 22:33:21 mike Exp $
3 // Z39.50 Connection class
9 connection::connection(const string &hostname, int portnum) {
10 const char *line_printer_size_hostname = hostname.c_str();
11 //###cerr << "opening " << hostname << ":" << portnum << "\n";
12 c = ZOOM_connection_new(line_printer_size_hostname, portnum);
13 //###cerr << "opened, got " << c << "\n";
16 const char *errmsg; // unused: carries same info as `errcode'
18 if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) {
19 //###cerr << "oops: no connect, errcode=" << errcode << "\n";
20 throw bib1Exception(errcode, addinfo);
24 string connection::option(const string &key) const {
25 return ZOOM_connection_option_get(c, key.c_str());
28 bool connection::option(const string &key, const string &val) {
29 // No way to tell whether ZOOM_connection_option_set() accepts key
30 ZOOM_connection_option_set(c, key.c_str(), val.c_str());
34 connection::~connection() {
35 ZOOM_connection_destroy(c);