+ ioctl(socket->m_fd, FIONBIO, &non_block);
+}
+
+/*
+ * GSocket_SetTimeout()
+ */
+
+void GSocket_SetTimeout(GSocket *socket, unsigned long millisec)
+{
+ assert(socket != NULL);
+
+ socket->m_timeout = millisec;
+ /* Neither GLIBC 2.0 nor the kernel 2.0.36 define SO_SNDTIMEO or
+ SO_RCVTIMEO. The man pages, that these flags should exist but
+ are read only. RR. */
+ /* OK, restrict this to GLIBC 2.1. GL. */
+ /* Anyway, they seem to pose problems: I need to know the socket level and
+ it varies (may be SOL_TCP, SOL_UDP, ...). I disables this and use the
+ other solution. GL. */
+#if 0
+#ifdef CAN_USE_TIMEOUT
+ if (socket->m_fd != -1) {
+ struct timeval tval;
+
+ tval.tv_sec = millisec / 1000;
+ tval.tv_usec = (millisec % 1000) * 1000;
+ setsockopt(socket->m_fd, SOL_SOCKET, SO_SNDTIMEO, &tval, sizeof(tval));
+ setsockopt(socket->m_fd, SOL_SOCKET, SO_RCVTIMEO, &tval, sizeof(tval));
+ }
+#endif
+#endif