2 * A dummy Socket implementation which just holds an error message.
19 static Plug
*sk_error_plug(Socket
*s
, Plug
*p
)
21 ErrorSocket
*es
= container_of(s
, ErrorSocket
, sock
);
28 static void sk_error_close(Socket
*s
)
30 ErrorSocket
*es
= container_of(s
, ErrorSocket
, sock
);
36 static const char *sk_error_socket_error(Socket
*s
)
38 ErrorSocket
*es
= container_of(s
, ErrorSocket
, sock
);
42 static SocketPeerInfo
*sk_error_peer_info(Socket
*s
)
47 static const SocketVtable ErrorSocket_sockvt
= {
48 .plug
= sk_error_plug
,
49 .close
= sk_error_close
,
50 .socket_error
= sk_error_socket_error
,
51 .peer_info
= sk_error_peer_info
,
52 /* other methods are NULL */
55 Socket
*new_error_socket_consume_string(Plug
*plug
, char *errmsg
)
57 ErrorSocket
*es
= snew(ErrorSocket
);
58 es
->sock
.vt
= &ErrorSocket_sockvt
;
64 Socket
*new_error_socket_fmt(Plug
*plug
, const char *fmt
, ...)
70 msg
= dupvprintf(fmt
, ap
);
73 return new_error_socket_consume_string(plug
, msg
);