 class SocketServer {
 private:
 	int sock;
+	int port;
 	bool done;
-	sockaddr_in addr;
 
 public:
 	SocketServer() {
 		sock = -1;
+		port = -1;
 		done = false;
-
-		sock = socket(PF_INET, SOCK_STREAM, 0);
-		if (sock == -1) {
-			fprintf(stderr, "problem creating socket: %s\n", strerror(errno));
-		}
-
-		addr.sin_family = AF_INET;
-		addr.sin_port = htons(SERVER_SOCKET_PORT);
-		addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 	}
 
 	~SocketServer() {

	return result;
}

__global__ void device_method(SocketClient *d_object) {

	int val = d_object->getValue();
	cuPrintf("Device object value: %d\n", val);
	d_object->setValue(++val);
	__threadfence();
}

int main(void) {

	SocketServer *socketServer = new SocketServer();

	pthread_t t;
	pthread_create(&t, NULL, &SocketServer::SocketServer_thread, &socketServer);

	SocketClient *host_object;
	SocketClient *device_object;

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

	// init pinned memory
	checkCuda(
			cudaHostAlloc((void**) &host_object, sizeof(SocketClient),
					cudaHostAllocWriteCombined | cudaHostAllocMapped));

	// init value
	host_object->setValue(0);
	printf("Host object value: %d\n", host_object->getValue());

	checkCuda(cudaHostGetDevicePointer(&device_object, host_object, 0));

	// initialize cuPrintf
	cudaPrintfInit();

	device_method<<<16, 4>>>(device_object);

	// display the device's output
	cudaPrintfDisplay();
	// clean up after cuPrintf
	cudaPrintfEnd();

	printf("Host object value: %d (after gpu execution) (thread_num=%d)\n",
			host_object->getValue(), 16 * 4);

	assert(host_object->getValue() == 16*4);

	return 0;
}


#include <cuda_runtime.h>

/********************************************/
/*************** MESSAGE_TYPE ***************/
/********************************************/
enum MESSAGE_TYPE {
	GET_NEXT_VALUE,
};

/********************************************/
/***************    Server    ***************/
