PDA

Click to See Complete Forum and Search --> : Net work game


Matt_T_hat
May 27th, 2002, 09:18 AM
Haveing carefully put togeather and tested my latest project I find that it is now time to look at the final stage. NETWORK play. the whole design is so that it will work over a LAN (peer-to-peer). I would prefer to ensure it works over the WWW as well.

How do I go about doing this (the LAN bit)? How do I send data from one example of the game to the other.

BTW: what's a good working practice to ensure that the data held by both does not differ.

VBD
May 30th, 2002, 04:24 PM
This will work over the internet. Have each user select wether they are a host or a client. Then if they are a client have them specify the IP address of a host.
the code could look something like this.
Also, put a winsock control on the from
Sub ConnectToOtherComputer_Click()
If host = true then
Winsock1.Localport = 954
Winsock1.Listen
Else
Winsock1.Connect TextboxRemoteUser.Text,954
End If
Close
Private Sub Winsock1_ConnectRequest(RequestID as integer)
If host = true then
winsock1.accept requestid
end if
End Sub
Private Sub Winsock1_Connect()
MsgBox("Connected")
end sub
Private Sub Winsock1_DataArrival(BytesTotal as Long)
Dim DataX as String
Winsock1.Getdata Datax 'Store the data
'the other'computer 'sent 'in variable called DataX
End Sub
Sub SendDataToOtherComputer(Data as String)
Winsock1.Senddata Data
End Sub


You get the idea, use Winsock1.Localport = 943 Winsock1.Listen to host
Use Winsock1.Connect RemoteIP,943 to connect.
Use Winsock1.Accept RequestID to accept a connecting User.
The Connect Sub is for if a client connects to you.
To getdata create a variable and go Winsock1.GetData Variable
To senddata Winsock1.Senddata Data. there should be lots of tutorials on this.

Fox
May 31st, 2002, 02:10 AM
Crappy formatted code..

*cough*

Just wanted to say: LAN or internet means the same as long as you connect through TCP/IP. In most cases internet connections are way slower, you might want to take care about this by interpolating movement however.

Matt_T_hat
Sep 15th, 2002, 03:10 PM
Ok thanx. (I think)

I've not experimented with LANs n WANs up till now. I think I get the drift. Hopefully the actuall data sent shouldn't be too big. As the state of playing peaces is secret I wonder if the two program examples should tell each other what is held or ask each other for results....

hmmm...