Files
QtGameMaker/help/files/413_01_connection.html
T

108 lines
4.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Setting up a connection</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body background="images/back.gif">
<!--START-->
<h3>Setting up a connection</h3>
For two computer to communicate they will need some connection protocol.
Like most games, <i>Game Maker</i> offers four different types of connections:
IPX, TCP/IP, Modem, and Serial. The IPX connection (to be more precise,
it is a protocol) is almost completely transparent. It can be used to
play games with other people on the same local area network. It needs to
be installed on your computer to be used. (If it does not work, consult
the documentation of Windows. Or go to the Network item in the control
panel of Windows and add the IPX protocol.) TCP/IP is the internet protocol.
It can be used to play with other players anywhere on the internet,
assuming you know their IP address. On a local network you can use it
without providing addresses. A modem connection is made through the
modem. You have to provide some modem settings (an initialization
string and a phone number) to use it. Finally, when using a serial
line (a direct connection between the computers) you need to provide
a number of port settings. There are four GML functions that can be
used for initializing these connections:
<p>
<blockquote>
<tt><b>mplay_init_ipx()</b></tt>
initializes an IPX connection.<br>
<tt><b>mplay_init_tcpip(addr)</b></tt>
initializes a TCP/IP connection. addr is a string containing the web
address or IP address, e.g. 'www.gameplay.com' or '123.123.123.12',
possibly followed by a port number (e.g. ':12'). Only when joining a
session (see below) do you need to provide an address. On a local
area network no addresses are necessary.<br>
<tt><b>mplay_init_modem(initstr,phonenr)</b></tt>
initializes a modem connection. initstr is the initialization
string for the modem (can be empty). phonenr is a string that
contains the phone number to ring (e.g. '0201234567'). Only when
joining a session (see below) do you need to provide a phone number.<br>
<tt><b>mplay_init_serial(portno,baudrate,stopbits,parity,flow)</b></tt>
initializes a serial connection. portno is the port number (1-4).
baudrate is the baudrate to be used (100-256K). stopbits indicates
the number of stopbits (0 = 1 bit, 1 = 1.5 bit, 2 = 2 bits). parity
indicates the parity (0=none, 1=odd, 2=even, 3=mark). And flow indicates
the type of flow control (0=none, 1=xon/xoff, 2=rts, 3=dtr, 4=rts and dtr).
Returns whether successful. A typical call is mplay_init_serial(1,57600,0,0,4).
Give 0 as a first argument to open a dialog for the user to change the settings.<br>
</blockquote>
<p>
Your game should call one of these functions exactly once. All functions report
whether they were successful. They are not successful if the particular protocol
is not installed or supported by your machine. To check whether there is a
successful connection available you can use the following function
<p>
<blockquote>
<tt><b>mplay_connect_status()</b></tt>
returns the status of the current connection. 0 = no connection,
1 = IPX connection, 2 = TCP/IP connection, 3 = modem connection,
and 4 = serial connection.<br>
</blockquote>
<p>
To end the connection call
<p>
<blockquote>
<tt><b>mplay_end()</b></tt>
ends the current connection.<br>
</blockquote>
<p>
When using a TCP/IP connection you might want to tell the person you want to play
the game with what the ip address of your computer is. The following function helps you here:
<p>
<blockquote>
<tt><b>mplay_ipaddress()</b></tt>
returns the IP address of your machine (e.g. '123.123.123.12') as a
string. You can e.g. display this somewhere on the screen. Note that
this routine is slow so don't call it all the time.<br>
</blockquote>
<!--END-->
</body>
</html>
<!-- KEYWORDS
connections
modem connections
ip address
ipx
mplay_init_ipx()
mplay_init_tcpip()
mplay_init_modem()
mplay_init_serial()
mplay_connect_status()
mplay_end()
mplay_ipaddress()
-->