void process_client(void *arg)
{
	int i;
	char b;
	t_buffer *buffers[4];
	t_buffer buffer[4];
	t_rinoosocket *socket = arg;

	buffer_static(&buffer[0], big_buffer, BUFFER_SIZE);
	buffers[0] = &buffer[0];
	rinoo_log("server - client accepted");
	rinoo_log("server - sending %d bytes", BUFFER_SIZE);
	XTEST(rinoo_socket_writev(socket, buffers, 1) == BUFFER_SIZE);
	rinoo_log("server - receiving 'b'");
	XTEST(rinoo_socket_read(socket, &b, 1) == 1);
	XTEST(b == 'b');
	for (i = 0; i < 4; i++) {
		buffer_static(&buffer[i], big_buffer + (i * (BUFFER_SIZE / 4)), BUFFER_SIZE / 4);
		buffers[i] = &buffer[i];
	}
	rinoo_log("server - sending %d bytes", BUFFER_SIZE);
	XTEST(rinoo_socket_writev(socket, buffers, 4) == BUFFER_SIZE);
	rinoo_log("server - receiving 'b'");
	XTEST(rinoo_socket_read(socket, &b, 1) == 1);
	XTEST(b == 'b');
	rinoo_log("server - receiving nothing");
	XTEST(rinoo_socket_read(socket, &b, 1) == -1);
	rinoo_socket_destroy(socket);
}
Beispiel #2
0
void client_func(void *unused(arg))
{
	t_buffer buffer;
	t_socket *client;

	client = rinoo_tcp_client(rinoo_sched_self(), IP_LOOPBACK, 4242, 0);
	XTEST(client != NULL);
	str = malloc(sizeof(*str) * TRANSFER_SIZE);
	XTEST(str != NULL);
	memset(str, 'a', TRANSFER_SIZE);
	buffer_static(&buffer, str, TRANSFER_SIZE);
	XTEST(rinoo_socket_writeb(client, &buffer) == TRANSFER_SIZE);
	rinoo_socket_destroy(client);
}