Convenience function for simple hello.

This commit is contained in:
Ian Gulliver
2016-02-28 12:45:00 -08:00
parent 161ea56d45
commit fdafe2e055
3 changed files with 14 additions and 13 deletions

View File

@@ -136,6 +136,18 @@ void send_new_wrapper(int fd, void *passthrough, struct peer *on_close) {
send_new(fd, (struct serializer *) passthrough, on_close);
}
bool send_new_hello(int fd, struct serializer *serializer, struct peer *on_close) {
struct buf buf = BUF_INIT, *buf_ptr = &buf;
send_hello(&buf_ptr, serializer);
if (buf_ptr->length) {
if (write(fd, buf_at(buf_ptr, 0), buf_ptr->length) != (ssize_t) buf_ptr->length) {
return false;
}
}
send_new(fd, serializer, on_close);
return true;
}
void send_hello(struct buf **buf_pp, void *passthrough) {
struct serializer *serializer = (struct serializer *) passthrough;
if (serializer->hello) {