--- a/src/sock_internal.h Sun Feb 22 05:27:29 2009 +0200
+++ b/src/sock_internal.h Sun Feb 22 06:44:16 2009 +0200
@@ -10,10 +10,10 @@
/* method table */
struct sock_stream_methods {
/* Normal read(2) */
- int (*read) (struct sock_stream *sock, void *buf, size_t len);
+ err_t (*read) (struct sock_stream *sock, void *buf, size_t len);
/* Normal write(2) */
- int (*write) (struct sock_stream *sock, const void *buf, size_t len);
+ err_t (*write) (struct sock_stream *sock, const void *buf, size_t len);
} methods;
};
@@ -25,9 +25,21 @@
* as appropriate.
*/
struct sock_stream {
+ /* The sock_stream_type for this socket */
struct sock_stream_type *type;
+
+ /* Last error info */
+ struct error_info err;
};
#define SOCK_FROM_BASE(sock, type) ((type*) sock)
+#define SOCK_ERR(sock) ((sock)->err)
+
+/*
+ * Initialize a sock_stream with the given sock_stream_type.
+ *
+ * The sock_stream should be initialized to zero. It is a bug to call this twice.
+ */
+void sock_stream_init (struct sock_stream *sock, struct sock_stream_type *type);
#endif /* SOCK_INTERNAL_H */