Hi, I am developing a game, and
Client:
REM Multiplayer
hostip$="0.0.0.0:Error"
clientname$="Unknown Player"
Input "Please enter the server IP and press return.: ",hostip$
sync
Print "Connecting to the following IP address: "+ hostip$
Print "Please Wait..."
connectstate=net connect (hostip$)
net set port 7970
if connectstate=0 then Print "Failed to connect, was the IP entered incorrectly? Did you enter the port (default 7970)? Press any key to quit" : wait key : end
Print "Waiting for ping. Please wait a few seconds"
repeat
received = net get message()
until received=1
Print "Recieved ping. Confirming connection, please wait for a few seconds"
net put word pingmenewplayer
net send (0)
Input "Please enter a unique username and press return: ",clientname$
Net put string clientname$
Net Send (0)
Print "Your new username ("+clientname$+") is valid. You will now be added to the game."
Print "Please Wait..."
set window off
Print "Connected."
wait 500
//And here the game starts.
Server:
sync rate 60
Set display mode 640,320,32
wait 200
player1ScX as float
player1ScY as float
Print "Server Software Started at "+get time$()+" on the Date of (MM/DD/YY) "+get date$()+"."
Print get time$() + " [server] Loading server"
wait 200
net host 64,"192.168.1.64"
net set port 7970
Print get time$() + " [server] Host started on port 7970"
Print get time$() + " [server] Waiting for players to join"
Print get time$() + " [server status update]" + str$(net get player amount()) + " players online."
`Wait for someone to connect
repeat
player = net player joined()
until player>0
Print get time$() + " [server] A player is attempting to connect"
newplayer = net player joined()
Print get time$() + " [server] Player has been assigned number " + str$(newplayer)
I will explain now that I know that the above code will only work with one player, and I will add to the code once I know it works.
The port 7970 is forwarded on my router (Bt Home Hub 3) and I am connected with powerline (homeplug). I run Minecraft and Just Cause 2 servers fine with this port (not at the same time), and both require port forwarding. Therefore, I assume that the ports are forwarded.
If I enter my local loopback address, I can connect to the server, and the server software prints the confirmation.
However, when I give my friend my IP, which is 86.169.xx.xxx (i replaced some numbers with x's), which I give him for my MC/JC2 server, he cannot connect, and the server does not receive the message.
Is there anything wrong with my code/something I need to add?
Any Idea's?
Thanks guys