+#endif /* !HAVE_INET_ATON */
+
+/* resolve host with also IP address parsing */
+int resolve_host(struct in_addr *sin_addr, const char *hostname)
+{
+ struct hostent *hp;
+
+ if (!inet_aton(hostname, sin_addr)) {
+ hp = gethostbyname(hostname);
+ if (!hp)
+ return -1;
+ memcpy(sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
+ }
+ return 0;
+}
+
+int ff_socket_nonblock(int socket, int enable)
+{
+#if HAVE_WINSOCK2_H
+ return ioctlsocket(socket, FIONBIO, &enable);
+#else
+ if (enable)
+ return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
+ else
+ return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
+#endif
+}
+#endif /* CONFIG_NETWORK */