예제 #1
0
int fix_message_send(struct fix_message *self, int sockfd, int flags)
{
    size_t msg_size;
    int ret = 0;

    TRACE(LIBTRADING_FIX_MESSAGE_SEND(self, sockfd, flags));

    if (!(flags & FIX_SEND_FLAG_PRESERVE_BUFFER))
        fix_message_unparse(self);

    buffer_to_iovec(self->head_buf, &self->iov[0]);
    buffer_to_iovec(self->body_buf, &self->iov[1]);

    ret = io_sendmsg(sockfd, self->iov, 2, 0);

    msg_size = fix_message_size(self);

    if (!(flags & FIX_SEND_FLAG_PRESERVE_BUFFER)) {
        self->head_buf = self->body_buf = NULL;
    }

    TRACE(LIBTRADING_FIX_MESSAGE_SEND_RET());

    if (ret >= 0)
        return msg_size - ret;
    else
        return ret;
}
예제 #2
0
int fix_message_send(struct fix_message *self, int sockfd, int flags)
{
	struct iovec iov[2];
	int ret = 0;

	fix_message_unparse(self);

	buffer_to_iovec(self->head_buf, &iov[0]);
	buffer_to_iovec(self->body_buf, &iov[1]);

	if (xwritev(sockfd, iov, ARRAY_SIZE(iov)) < 0) {
		ret = -1;
		goto error_out;
	}

error_out:
	self->head_buf = self->body_buf = NULL;

	return ret;
}