1 // $Header: /home/cvsroot/yaz++/zoom/zconn.cpp,v 1.9 2005-06-25 15:53:21 adam Exp $
3 // Z39.50 Connection class
9 connection::connection() {
10 ZOOM_options o = ZOOM_options_create();
11 c = ZOOM_connection_create(o);
14 void connection::connect(const std::string &hostname, int portnum) {
15 const char *line_printer_size_hostname = hostname.c_str();
16 //###cerr << "opening " << hostname << ":" << portnum << "\n";
17 ZOOM_connection_connect(c, line_printer_size_hostname, portnum);
18 //###cerr << "opened\n";
21 const char *errmsg; // unused: carries same info as `errcode'
23 if ((errcode = ZOOM_connection_error(c, &errmsg, &addinfo)) != 0) {
24 //###cerr << "oops: no connect, errcode=" << errcode << "\n";
25 throw bib1Exception(errcode, addinfo);
29 connection::connection(const std::string &hostname, int portnum) {
30 ZOOM_options o = ZOOM_options_create();
31 c = ZOOM_connection_create(o);
32 connect(hostname, portnum);
35 std::string connection::option(const std::string &key) const {
36 const char* val = ZOOM_connection_option_get(c, key.c_str());
37 return (val) ? val : std::string();
40 bool connection::option(const std::string &key, const std::string &val) {
41 // No way to tell whether ZOOM_connection_option_set() accepts key
42 ZOOM_connection_option_set(c, key.c_str(), val.c_str());
46 connection::~connection() {
47 ZOOM_connection_destroy(c);
53 * indent-tabs-mode: nil
55 * vim: shiftwidth=4 tabstop=8 expandtab