Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Error in Multisync, game online

Author
Message
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 29th Jul 2013 02:18
Hello! I'm using thats codes:
server


client

Works only on LAN, but between computers in different houses not!
What i do?
Remembering... the server creates an file ip.net and i post it in path of client

Oh, thats how i get my ip:


"Better than do is try"
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Jul 2013 05:15 Edited at: 29th Jul 2013 05:16
lately i've been messing with the native dbpro multiplayer commands and, most-recently, with multisync.

i think we're in the same situation where we're unable to retrieve the WAN(?) address that the world can use if you're behind a router where the commands you're using will retrieve only the LAN address that only systems within your network can access.


currently, i'm trying to figure out how to retrieve the ip address provided by websites such as icanhazip.com where the ip address is clean/without a buncha ads or other info that i don't want to deal with. simply xxx.xxx.xxx.xxx

just now started looking at the native http commands... not able to retrieve the ip from the site yet but i think i'm on the right path to retrieving actual web IP address when behind a router which, i believe, is where you're finding yourself, now.

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 29th Jul 2013 05:59
I used the ip provided by this site and the program just crashed!

"Better than do is try"
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 29th Jul 2013 06:46 Edited at: 29th Jul 2013 07:05
There is a built in command to get LAN IP:
multiplayer get ip address()

For WAN IP this is the function I use:



Now keep in mind, simply getting the WAN IP is not enough, you also need to set up port forwarding for the server/host on that machine's router.

This site http://portforward.com/ has a lot of good simple information on the subject, even if it does have a lot of ad banners.

Here is a short connection test which allows you to host an instance or connect to an instance over LAN or WAN (assuming you have the forwarding set up correctly, personally recommend setting up your host with a static LAN IP as it just makes things easier):

*note uses hitimer from matrix1, if you don't have the plugin (go get it! no excuse!) you can replace that with the built in perftimer to run it.



Shazam!
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Jul 2013 15:59 Edited at: 29th Jul 2013 16:10
@TheGourglex, as i understand it, if the client is connecting to a host that is within the same network, it'll need to use the LAN address or it will crash. when others, outside your network, want to join, they'll use the WAN address.

@Ortu, ideally, we could read a file from the web without having to save, load, read, then delete it. hence my looking into the native http commands (which i can't make heads nor tails out of...). alas, your method allows me to move forward. thanks for that!

meanwhile, i've never seen always active. a quick search revealed it's an un-documented dbpro command. i thought dbpro is "always active" by default? is there a benefit to using it that i don't understand? ie, why do you include it?

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 29th Jul 2013 21:15
honestly, its just a habit from DBC, if you ran multiple instances, ie a server and a client on the same machine, if you didnt set always active on then the server would stop processing when you switch to the client. i dont know if it makes a difference in DBPro but i just tend to stick in anyways.

as far as the http commands, the problem with using them on a third party site is that the httprequest will return a whole page of html, not just the ip string you want, you will have to parse through it and i find it easier to do that with a file.

if you have your own web site/host, you can httprequest against a script that you know will give you exactly the data you want and you can eliminate the file processing. most here dont have that sort of setup though. i have some code that sends and retrieves data from a php script, this may help you, i will post when i get home tonight.

Shazam!
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Jul 2013 02:32
Quote: " i have some code that sends and retrieves data from a php script"

looking forward to it. thanks.

@TheGourglex, i didn't mean to hijack your thread tho your issue sounds like it is directly related to mine. if the above doesn't help your situation, please advise?

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 30th Jul 2013 09:56 Edited at: 30th Jul 2013 09:59
hmm well I seem to have misplaced it, it's been a while since I did anything with that and I forget where exactly I saved it

But, I did come across this in the snippets folder that comes with DBpro (\dark basic pro\projects\snippets\httpaccess\httpaccess.dba)

It returns the WAN IP (I ran it and verified) using the http commands, and should be quite easy to functionize.



Shazam!
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 31st Jul 2013 03:17
that'll work. thanks a lot, ortu

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 3rd Aug 2013 00:35
Thank's everybody!
But i got my wan ip and the error is the same: TIME OUTED.
Here's my new code:
server


client


"Better than do is try"
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 3rd Aug 2013 00:41
oh, and i release the port 8000

"Better than do is try"
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 3rd Aug 2013 01:53
might need to add your application to your antivirus whitelist,also sometimes windows will give host a prompt when a client tries to connect something like "do you want to allow incoming connections...blah blah blah" if it does click yes.

most likely though it is an issue with port forwarding, it can be tricky to setup right.

Shazam!
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 3rd Aug 2013 02:08
I'll try with the AVG off.
Oh, another issue how do you test your server programs? Because it seems that in the same computer gives error!
Do you use virtual machines like Microsoft Virtual PC?
Oh, and i free the port 3999 and the same error happen

"Better than do is try"
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 3rd Aug 2013 02:34
when i change

to

an error occurs!

"Better than do is try"
Seditious
12
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 3rd Aug 2013 05:44
There are a few important things you must know when trying to host or join a game:

1. If the other person is connecting over the internet, they have to connect to your internet IP. If connecting over a LAN they have to use your LAN address (this is the address of your computer inside the local network, which can be found using ipconfig. You shouldn't need to enter an IP in net host since that's only for selecting a specific network interface. Trying to use the internet IP will give you an error.

2. Both the host and client machines need to have the exe allowed in any firewalls that are enabled. Instructions for adding a program to Windows Firewall can be found here, or via a quick Google search.

3. As the host you must forward the relevant port to your computer, in this case TCP 3999. Check out portforward.com for easy instructions on how to set up port forwarding on many different routers. Failure to set up port forwarding means the router will receive a connection request from the client but will not know which computer inside the network to forward it to, so a connection never succeeds. The client does not need to set up port forwarding.

Quote: "an error occurs!"


Just for future reference, it'd be good to mention what that error is so that we can help you further. Most of us aren't psychic.

Formerly Benjamin.
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 3rd Aug 2013 18:43 Edited at: 3rd Aug 2013 18:44
Thank Benjamin!
I keep having some mistakes, so here\'s what I did:
1. I released the port 3999 with the IP obtained by the command ipconfig.
(see the first image in the file)
2. I use this code as server:

3. I use this code as client:

4. See that the fireall problem had been solved, since in the beginning of the code the program server.exe was enabled.
(see the second and third images)
5. The server is ok, but when my friend open the client.exe (in the same time that server.exe was running in my pc), the error \"Timed out\" occurred!
Oh, and i have some questions:
1. Do execute server.exe and client.exe in the same pc generate an error?
2. Do execute server.exe in the real machine and client.exe in the virtual machine (program Microsoft Virtual PC) generate the same error in question 1?
3. Should my antivirus (AVG) be disabled?
4. How do you test yours server/client programs?
PS.: if I make a mistake in English, I would like you to correct me, for me to improve my language, because I\'m Brazilian

"Better than do is try"
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 3rd Aug 2013 18:52 Edited at: 3rd Aug 2013 18:54
I just run server and client on the same basic machine without issue. I still think your problem is the forwarding. it's not simply a matter of opening a port on the server pc, it involves logging in to your router and setting up a rule which tells it to send communication on the specific port to the server LAN ip. if you have server using dhcp for its LAN ip you have to change this forward rule on router every time sever ip changes, this is why I recommend setting server to a static ip that won't ever change or conflict with other dhcp devices.

net set host(10) just sets the max number of allowed connections, as far as I know there is no need to pass anything other than your desired player count to this command

no need and not recommended to disable antivirus, just add your program to its list of allowed programs

Shazam!
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 3rd Aug 2013 19:15
Quote: "
it's not simply a matter of opening a port on the server pc, it involves logging in to your router and setting up a rule which tells it to send communication on the specific port to the server LAN ip
"

how?
Quote: "
if you have server using dhcp for its LAN ip you have to change this forward rule on router every time sever ip changes
"

what's dhcp? :s

"Better than do is try"
Seditious
12
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 3rd Aug 2013 23:33
Connecting to yourself on the same PC (ie. running both a server and client on your computer) is done slightly differently than if someone on the internet is connecting to you. Just to be clear, you have to connect using your PC's LAN address (192.168.1.2), which I assume you're already doing. It shouldn't be necessary to specify an IP in net host.

Your port forwarding configuration looks fine, although perhaps you could leave the "external port start" and "external port end" fields empty. Also, forwarding should not be necessary if you are trying to connect to the server on your own PC (it's only for connecting across the internet).

It's been so long since I've worked on MS that I don't remember it so well, so maybe you've made a mistake in your code that I haven't recognised. Do any of the examples work for you?

Formerly Benjamin.
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 4th Aug 2013 01:52 Edited at: 4th Aug 2013 01:52
Ah, I didn't see your screenshots attachment. Yeah, the forwarding looks correct.

A quick way to test for sure:
This tool will tell you if you have the port working properly and can send and receive through it:

http://portforward.com/help/portcheck.htm

Have you tried compiling the second (full) snippet i posted and running it unmodified? it can act as server or client, can connect over LAN or WAN.

run it once and host a session. run another instance and connect using LAN option. run a third instance and connect using WAN option. you should see something like this:



Shazam!
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 4th Aug 2013 02:28
I tested your code Ortu:

I execute as host, after as LAN and, when i test WAN, the same error (Timed out) ocurred

"Better than do is try"
Seditious
12
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 4th Aug 2013 07:09
You can't connect to yourself via your WAN (internet) address.

Formerly Benjamin.
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 5th Aug 2013 03:47
the only way i test host/client programs is with the friend's help?

"Better than do is try"
Seditious
12
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 5th Aug 2013 03:54
No, it's possible to do it on the same computer, but you must use your LAN address when connecting (I think it's 192.168.1.2 as you showed previously).

Formerly Benjamin.
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 5th Aug 2013 06:11
Quote: "the only way i test host/client programs is with the friend's help?"

use the LAN address.

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 5th Aug 2013 19:40
But i need to test WAN!

"Better than do is try"
Seditious
12
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 5th Aug 2013 20:21
WAN is internet, and the only way you can test that is by having someone connect from the internet.

Formerly Benjamin.
Virtual Nomad
Moderator
20
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Aug 2013 03:55
Quote: "But i need to test WAN!"

unplug the network and connect a computer directly to the internet? otherwise, that's what friends are for

Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 8th Aug 2013 00:00
I still can not connect to WAN

"Better than do is try"

Login to post a reply

Server time is: 2026-07-06 20:52:53
Your offset time is: 2026-07-06 20:52:53