-
-/* SockDataWaiting: Return a non-zero value if this socket is waiting
- for data. */
-int SockDataWaiting(int socket)
-{
- int flags;
- char sbuf[INTERNAL_BUFSIZE];
- int n;
- int res;
- flags = fcntl(socket,F_GETFL,0);
-
- /* set it to non-block */
- if (fcntl(socket,F_SETFL,flags | O_NONBLOCK) == -1)
- return -1;
-
- if ((n = recv(socket,sbuf,INTERNAL_BUFSIZE,MSG_PEEK)) == -1)
- {
- /* No data to read. */
- if (errno == EWOULDBLOCK)
- res = 0;
- }
- else
- res = n;
-
- /* reset it to block (or, whatever it was). */
- fcntl(socket,F_SETFL,flags);
- return res;
-}
-#if defined(HAVE_STDARG_H)
-int SockPrintf(int socket, char* format, ...)
+#ifdef MAIN
+/*
+ * Use the chargen service to test input beuffering directly.
+ * You may have to uncomment the `chargen' service description in your
+ * inetd.conf (and then SIGHUP inetd) for this to work.
+ */
+main()