-// err points to where the error from netopen() should be stored
-PUBLIC_FN FILE *fnetopen(const char *node, const char *service, const struct addrinfo *hints, int *err) {
- int rval = netopen(node, service, hints);
- if (rval < 0) goto err;
+PUBLIC_FN int fnetopen(FILE **in, FILE **out, const char *node, const char *service, const struct addrinfo *hints) {
+ int fd = netopen(node, service, hints);
+ if (fd < 0) return EAI_SYSTEM;
+ int ret = fopen_bistream(in, out, fd, 0);
+ if (ret) close(fd);
+ return ret;
+}
+
+HEADER // negative return value for error, else a socket
+PUBLIC_FN int netopen_server(const char *node /*NULL for ANY*/, const char *service, const struct addrinfo *hints) {
+ struct addrinfo hints_;
+ if (hints == &libjh_tcp_hints) {
+ hints_ = *hints;
+ hints_.ai_flags |= AI_PASSIVE;
+ hints_.ai_flags &= ~AI_ADDRCONFIG;
+ hints = &hints_;
+ }
+
+ struct addrinfo *addrs;
+ int gai_res = getaddrinfo(node, service, hints, &addrs);
+ if (gai_res) return gai_res;