 
 	sleep(2);
 
-	host_client->sendDone();
+	socket_client.sendDone();
 	// wait for SocketServer
 	pthread_join(t_socket_server, NULL);
 

	sigIntHandler.sa_flags = 0;
	sigaction(SIGINT, &sigIntHandler, NULL);

	// start socketServer
	pthread_create(&t_socket_server, NULL, &SocketServer::thread,
			&socket_server);

	// runtime must be placed into a state enabling to allocate zero-copy buffers.
	checkCuda(cudaSetDeviceFlags(cudaDeviceMapHost));

	// init host socket client as pinned memory
	checkCuda(
			cudaHostAlloc((void**) &host_client, sizeof(SocketClient),
					cudaHostAllocWriteCombined | cudaHostAllocMapped));

	// connect SocketClient
	host_client->connectSocket(socket_server.getPort());

	int value = host_client->getNextValue(0);
	printf("Host client getNextValue: %d\n", value);

	SocketClient *device_client;
	checkCuda(cudaHostGetDevicePointer(&device_client, host_client, 0));

	// initialize cuPrintf
	cudaPrintfInit();

	//device_method<<<1, 1>>>(device_client);
	//device_method<<<16, 4>>>(device_client);

	// display the device's output
	cudaPrintfDisplay();

	return result;
}

__global__ void device_method(KernelWrapper *d_kernelWrapper) {

	int thread_id = threadIdx.x + blockIdx.x * blockDim.x;
	atomicExch(&d_kernelWrapper->active_thread_id, thread_id);

	if (d_kernelWrapper->active_thread_id == thread_id) {

		int val = d_kernelWrapper->getValue(thread_id);
		cuPrintf("Device object value: %d\n", val);
	}
}

int main(void) {
