-/* Ship a character array to the socket */
-#define SockWrite(buf, len, sockfp) fwrite(buf, 1, len, sockfp)
+/**
+Send formatted output to the socket (matches interface of fprintf).
+Returns number of bytes successfully written.
+*/
+#if defined(HAVE_STDARG_H)
+int SockPrintf(int sock, const char *format, ...)
+ __attribute__ ((format (printf, 2, 3)))
+ ;
+#else
+int SockPrintf();
+#endif
+
+/**
+Close a socket previously opened by SockOpen. This allows for some
+additional clean-up if necessary.
+*/
+int SockClose(int sock);