X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=doc%2Fcomstack.xml;h=846b50729cc1275b6def23daa5c542fce8b3673f;hp=0be19367559a21c6417430dec56e2fee4a20937e;hb=d51b21c6f41a021f21078921a0de50106264d55e;hpb=c2317ad6444bd2a90a45fd519f286a7cef49c776 diff --git a/doc/comstack.xml b/doc/comstack.xml index 0be1936..846b507 100644 --- a/doc/comstack.xml +++ b/doc/comstack.xml @@ -1,56 +1,67 @@ The COMSTACK Module - + Synopsis (blocking mode) - - - -COMSTACK stack; -char *buf = 0; -int size = 0, length_incoming; -char *protocol_package; -int protocol_package_length; -char server_address_str[] = "myserver.com:2100"; -void *server_address_ip; -int status; - -stack = cs_create(tcpip_type, 1, PROTO_Z3950); -if (!stack) { - perror("cs_create"); /* use perror() here since we have no stack yet */ - exit(1); -} - -server_address_ip = cs_addrstr (stack, server_address_str); - -status = cs_connect(stack, server_address_ip); -if (status != 0) { - cs_perror(stack, "cs_connect"); - exit(1); -} - -status = cs_put(stack, protocol_package, protocol_package_length); -if (status) { - cs_perror(stack, "cs_put"); - exit(1); -} - -/* Now get a response */ - -length_incoming = cs_get(stack, &buf, &size); -if (!length_incoming) { - fprintf(stderr, "Connection closed\n"); - exit(1); -} else if (length_incoming < 0) { - cs_perror(stack, "cs_get"); - exit(1); -} - -/* Do stuff with buf here */ - -/* clean up */ -cs_close(stack); -if (buf) - free(buf); - + + @@ -68,7 +79,7 @@ if (buf) of losing generality, and it may prove that the interface will need extension later on. - + There hasn't been interest in the XTImOSI stack for some years. @@ -105,20 +116,20 @@ if (buf) COMSTACK cs_create(CS_TYPE type, int blocking, int protocol); - + Creates an instance of the protocol stack - a communications endpoint. The type parameter determines the mode of communication. At present the following values are supported: - + tcpip_type TCP/IP (BER over TCP/IP or HTTP over TCP/IP) ssl_type - Secure Socket Layer (SSL). This COMSTACK + Secure Socket Layer (SSL). This COMSTACK is experimental and is not fully implemented. If HTTP is used, this effectively is HTTPS. @@ -130,7 +141,7 @@ if (buf) - + The cs_create function returns a null-pointer if a system error occurs. @@ -142,7 +153,7 @@ if (buf) - int cs_close(COMSTACK handle); + void cs_close(COMSTACK handle); @@ -398,7 +409,7 @@ if (buf) - char *cs_addrstr(COMSTACK); + const char *cs_addrstr(COMSTACK); @@ -439,22 +450,25 @@ if (buf) - For TCP/IP and SSL transport modes, the special hostname "@" - is mapped to any local address - (the manifest constant INADDR_ANY). - It is used to establish local listening endpoints in the server role. + For TCP/IP and SSL, the special hostnames @, + maps to IN6ADDR_ANY_INIT with + IPV4 binding as well (bindv6only=0), + The special hostname @4 binds to + INADDR_ANY (IPV4 only listener). + The special hostname @6 binds to + IN6ADDR_ANY_INIT with bindv6only=1 (IPV6 only listener). For UNIX sockets, the format of an address is the socket filename. - + When a connection has been established, you can use - char *cs_addrstr(COMSTACK h); + const char *cs_addrstr(COMSTACK h); @@ -482,9 +496,8 @@ if (buf) function cs_create. The third parameter vp is a pointer to &comstack; stack type specific values. - For SSL (ssl_type) vp is an already create - OpenSSL CTX. For TCP/IP and UNIX vp - is unused (can be set to NULL. + Parameter vp is reserved for future use. + Set it to NULL. @@ -529,7 +542,7 @@ if (buf) - + Diagnostics @@ -561,40 +574,39 @@ if (buf) const char *cs_errmsg(int n); - + It is also possible to get straight to the textual represenataion - without the error code by using + without the error code by using cs_strerror. - + const char *cs_strerror(COMSTACK h); - + Summary and Synopsis - - #include <yaz/comstack.h> - - #include <yaz/tcpip.h> /* this is for TCP/IP and SSL support */ - #include <yaz/unix.h> /* this is for UNIX sockeL support */ - - + + + #include /* this is for TCP/IP and SSL support */ + #include /* this is for UNIX socket support */ + COMSTACK cs_create(CS_TYPE type, int blocking, int protocol); - + COMSTACK cs_createbysocket(int s, CS_TYPE type, int blocking, int protocol); - COMSTACK cs_create_host (const char *str, int blocking, - void **vp); - + COMSTACK cs_create_host(const char *str, int blocking, + void **vp); + int cs_bind(COMSTACK handle, int mode); - + int cs_connect(COMSTACK handle, void *address); - + int cs_rcvconnect(COMSTACK handle); - + int cs_listen(COMSTACK handle); COMSTACK cs_accept(COMSTACK handle); @@ -605,21 +617,14 @@ if (buf) int cs_more(COMSTACK handle); - int cs_close(COMSTACK handle); + void cs_close(COMSTACK handle); int cs_look(COMSTACK handle); void *cs_straddr(COMSTACK handle, const char *str); - char *cs_addrstr(COMSTACK h); - - extern int cs_errno; - - void cs_perror(COMSTACK handle char *message); - - const char *cs_stackerr(COMSTACK handle); - - extern const char *cs_errlist[]; + const char *cs_addrstr(COMSTACK h); +]]>