add FOR_EACH_IN_ARRAY
[libjh.git] / net.c
diff --git a/net.c b/net.c
index d9b2d43..2fba39a 100644 (file)
--- a/net.c
+++ b/net.c
@@ -39,3 +39,11 @@ err_socket:
   freeaddrinfo(addrs);
   return EAI_SYSTEM;
 }
+
+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;
+}
\ No newline at end of file