|
@@ -132,31 +132,6 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
|
|
|
}
|
|
|
#endif /* CONFIG_LOCALTIME_R */
|
|
|
|
|
|
-void qemu_set_block(int fd)
|
|
|
-{
|
|
|
- unsigned long opt = 0;
|
|
|
- WSAEventSelect(fd, NULL, 0);
|
|
|
- ioctlsocket(fd, FIONBIO, &opt);
|
|
|
-}
|
|
|
-
|
|
|
-void qemu_set_nonblock(int fd)
|
|
|
-{
|
|
|
- unsigned long opt = 1;
|
|
|
- ioctlsocket(fd, FIONBIO, &opt);
|
|
|
- qemu_fd_register(fd);
|
|
|
-}
|
|
|
-
|
|
|
-int socket_set_fast_reuse(int fd)
|
|
|
-{
|
|
|
- /* Enabling the reuse of an endpoint that was used by a socket still in
|
|
|
- * TIME_WAIT state is usually performed by setting SO_REUSEADDR. On Windows
|
|
|
- * fast reuse is the default and SO_REUSEADDR does strange things. So we
|
|
|
- * don't have to do anything here. More info can be found at:
|
|
|
- * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx */
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
static int socket_error(void)
|
|
|
{
|
|
|
switch (WSAGetLastError()) {
|
|
@@ -233,6 +208,38 @@ static int socket_error(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void qemu_set_block(int fd)
|
|
|
+{
|
|
|
+ unsigned long opt = 0;
|
|
|
+ WSAEventSelect(fd, NULL, 0);
|
|
|
+ ioctlsocket(fd, FIONBIO, &opt);
|
|
|
+}
|
|
|
+
|
|
|
+int qemu_try_set_nonblock(int fd)
|
|
|
+{
|
|
|
+ unsigned long opt = 1;
|
|
|
+ if (ioctlsocket(fd, FIONBIO, &opt) != NO_ERROR) {
|
|
|
+ return -socket_error();
|
|
|
+ }
|
|
|
+ qemu_fd_register(fd);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void qemu_set_nonblock(int fd)
|
|
|
+{
|
|
|
+ (void)qemu_try_set_nonblock(fd);
|
|
|
+}
|
|
|
+
|
|
|
+int socket_set_fast_reuse(int fd)
|
|
|
+{
|
|
|
+ /* Enabling the reuse of an endpoint that was used by a socket still in
|
|
|
+ * TIME_WAIT state is usually performed by setting SO_REUSEADDR. On Windows
|
|
|
+ * fast reuse is the default and SO_REUSEADDR does strange things. So we
|
|
|
+ * don't have to do anything here. More info can be found at:
|
|
|
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx */
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int inet_aton(const char *cp, struct in_addr *ia)
|
|
|
{
|
|
|
uint32_t addr = inet_addr(cp);
|