+ return GSOCK_NOERROR;
+}
+
+/* _GSocket_Output_Timeout:
+ * For blocking sockets, wait until data can be sent without
+ * blocking or until timeout ellapses.
+ */
+GSocketError _GSocket_Output_Timeout(GSocket *socket)
+{
+ struct timeval tv;
+ fd_set writefds;
+ int ret;
+
+ /* Linux select() will overwrite the struct on return */
+ tv.tv_sec = (socket->m_timeout / 1000);
+ tv.tv_usec = (socket->m_timeout % 1000) * 1000;
+
+ GSocket_Debug( ("m_non_blocking has: %d\n", (int)socket->m_non_blocking) );
+
+ if (!socket->m_non_blocking)
+ {
+ FD_ZERO(&writefds);
+ FD_SET(socket->m_fd, &writefds);
+ ret = select(socket->m_fd + 1, NULL, &writefds, NULL, &tv);
+ if (ret == 0)
+ {
+ GSocket_Debug(( "GSocket_Output_Timeout, select returned 0\n" ));
+ socket->m_error = GSOCK_TIMEDOUT;
+ return GSOCK_TIMEDOUT;
+ }
+ if (ret == -1)
+ {
+ GSocket_Debug(( "GSocket_Output_Timeout, select returned -1\n" ));
+ if (errno == EBADF) { GSocket_Debug(( "Invalid file descriptor\n" )); }
+ if (errno == EINTR) { GSocket_Debug(( "A non blocked signal was caught\n" )); }
+ if (errno == EINVAL) { GSocket_Debug(( "The highest number descriptor is negative\n" )); }
+ if (errno == ENOMEM) { GSocket_Debug(( "Not enough memory\n" )); }
+ socket->m_error = GSOCK_TIMEDOUT;
+ return GSOCK_TIMEDOUT;
+ }
+ if ( ! FD_ISSET(socket->m_fd, &writefds) ) {
+ GSocket_Debug(( "GSocket_Output_Timeout is buggy!\n" ));
+ }
+ else {
+ GSocket_Debug(( "GSocket_Output_Timeout seems correct\n" ));
+ }
+ }
+ else
+ {
+ GSocket_Debug(( "GSocket_Output_Timeout, didn't try select!\n" ));
+ }
+
+ return GSOCK_NOERROR;
+}
+
+int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
+{
+ return recv(socket->m_fd, buffer, size, 0);