12.07.2015 Views

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ExamplesRunning the program <strong>with</strong>out any parametersplanetp4activates peer-<strong>to</strong>-peer mode but does not connect <strong>to</strong> a network. To connect <strong>to</strong> an existing peer-<strong>to</strong>-peernetwork, runplanetp4 -s To start a second instance on the local machine, it is necessary <strong>to</strong> specify an alternate bind port:planetp4 -b 8586 -s localhostAlternatively, you can connect a bot <strong>to</strong> the network <strong>with</strong>planetp4 -b 8586 -s localhost -c -aFor client-server mode, it is necessary <strong>to</strong> start a dedicated server instance first:planetp4 -m cuspserverA client is connected using the following command line:planetp4 -m cuspclient -s On localhost, useplanetp4 -m cuspclient -b 8586 -s localhost4.6 CUSP BindingsPart <strong>of</strong> this work is <strong>to</strong> create C++ bindings <strong>to</strong> the Standard ML CUSP API. This section discusses the keypoints <strong>of</strong> that task.4.6.1 ConceptML<strong>to</strong>n’s foreign function interface 8 (FFI) allows calling C functions from Standard ML and exportingStandard ML functions <strong>to</strong> be called from C code. This is the basis for the C++ bindings. The filelibcusp.sml contains Standard ML glue code that exports C functions. From that file the ML<strong>to</strong>n compilergenerates a C header file (libcusp.h) which declares the exported functions. The header file is includedby the C++ wrapper code in cusp.c, which is compiled <strong>to</strong> an object file, which in turn ML<strong>to</strong>n finally adds<strong>to</strong> the archive containing the whole transport pro<strong>to</strong>col implementation, libcusp.a. To use the library,applications just have <strong>to</strong> include the C++ header file cusp.h and link libcusp.a <strong>to</strong> the the program. Figures4.8 and 4.9 depict the concept and the build process.8 http://ml<strong>to</strong>n.org/ForeignFunctionInterface66 4.6 CUSP Bindings

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!