Esempio n. 1
0
int main()
{
	GameServer::start(	12345	/* server port */,
						10,		/* update delay */
						10,		/* max connected players */
						2000	/* client timeout before disconnect*/);

	core_sleep(100);

	cout << "Enter user: "******"123345",		/* password (not checked) */
						"localhost",	/* server host */	
						12345,			/* server port */
						10				/* update delay */	);	

	while (!global_exit)core_sleep(1000);

	GameClient::stop();
	GameServer::stop();
	
	return 0;
}
Esempio n. 2
0
// Main
void start_client()
{
	core_sleep(1000);
	net::Rpc &r = client.get_rpc();
	rpc_register_local (r, hello_client);
	rpc_register_remote(r, hello_server);
	client.connect("localhost", 12345);
	

	while (1)
	{
		client.call("hello_server", "Greetings from Client", 2, 12.34, 5.1f, glm::vec3(1, 2, 3));
		client.process();
		core_sleep(1000);
	}
	//client.disconnect();
}
Esempio n. 3
0
// Main
void start_client()
{
	core_sleep(1000);
	net::Rpc &r = client.get_rpc();
	rpc_register_local (r, hello_client);
	rpc_register_remote(r, hello_server);
	client.connect("localhost", network_port, bps_down, bps_up, time_out, compress_data);
	
	while (client.connected())
	{
		loopi(0, 20) client.call("hello_server", "Greetings");

		client.process();

		// Comment in if memory usage increases due to queued packets
		//core_sleep(1);
	}
	//client.disconnect();
	core_sleep(1000);
	server.stop();
}
int device_data_transfer(open_file_t * open_file, void * buf, int nbyte, int read){
	int tmp;
	int mode;
	priv_device_data_transfer_t args;

	if ( nbyte == 0 ){
		return 0;
	}

	args.fs = (const sysfs_t*)open_file->fs;
	args.handle = (device_t *)open_file->handle;
	args.read = read;
	args.op.loc = open_file->loc;
	args.op.flags = open_file->flags;
	args.op.buf = buf;
	args.op.callback = priv_data_transfer_callback;
	args.op.context = &args;
#if SINGLE_TASK == 0
	args.op.tid = task_get_current();
#else
	args.op.tid = 0;
#endif

	if ( (mode = get_mode(args.fs, args.handle)) < 0 ){
		return -1;
	}

	//privilege call for the operation
	do {

#if SINGLE_TASK > 0
		waiting = false;
#endif
		args.op.nbyte = nbyte;
		args.ret = -101010;

		//This transfers the data
		hwpl_core_privcall(priv_device_data_transfer, &args);
		//We arrive here if the data is done transferring or there is no data to transfer and O_NONBLOCK is set
		//or if there was an error
		if( sched_get_unblock_type(task_get_current()) == SCHED_UNBLOCK_SIGNAL ){
			unistd_clr_action(open_file);
			errno = EINTR;
			return -1;
		}

#if SINGLE_TASK != 0
		while ( waiting == true ){
			core_sleep(CORE_SLEEP);
		}
#endif
		if ( args.ret > 0 ){
			//The operation happened synchronously
			tmp = args.ret;
			break;
		} else if ( args.ret == 0 ){
			//the operation happened asynchronously
			if ( args.op.nbyte > 0 ){
				//The operation has completed and transferred args.op.nbyte bytes
				tmp = args.op.nbyte;
				break;
			} else if ( args.op.nbyte == 0 ){
				//There was no data to read/write -- try again
				if (args.op.flags & O_NONBLOCK ){
					errno = ENODATA;
					return -1;
				}
			} else if ( args.op.nbyte < 0 ){
				//there was an error executing the operation (or the operation was cancelled)
				return -1;
			}
		} else if ( args.ret < 0 ){
			//there was an error starting the operation (such as EAGAIN)
			if( args.ret == -101010 ){
				errno = ENXIO; //this is a rare/strange error where hwpl_core_privcall fails to run properly
			}
			return -1;
		}
	} while ( args.ret == 0 );


	if ( ((mode & S_IFMT) != S_IFCHR) && (tmp > 0) ){
		open_file->loc += tmp;
	}

	return tmp;
}