Chat with Me -- HOST - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Chat with Me -- HOST (/showthread.php?tid=1262) |
Chat with Me -- HOST - SMcNeill - 12-11-2022 Now, as I mentioned in the topic Come chat with me! (qb64phoenix.com), I told you guys I was going to share the HOST part of the program which we were all using to play around and chat with yesterday -- and try to highlight the steps necessary to get it to run properly for everyone. First, let's start with the code. We'll begin with the HOST version of my Mini Messenger (qb64phoenix.com): Code: (Select All) DIM SHARED Users(1 TO 1000) ' array to hold other client info Now, I tried to keep this as simple as I possibly could -- without any bells or whistles to complicate the viewing and understanding of the basic process we're using here -- so don't think this is anything fancy at all. All this basically does is show how to set up a host connection, accept users trying to connect to that connection, and then transfer information back and forth between the two. It's a demo to showcase the very bare bones of the TCP/IP stuff, and nothing more, so keep that in mind as we go along and talk about things. First change needed to swap this over from LOCALHOST to world wide web hosting involves... dum dum de dum.... Opening a browser tab and going to What Is My IP? Shows Your Public IP Address - IPv4 - IPv6. If you're using a VPN or such to protect your IP, you may be able to get by with using it, or you may not. That all depends on your VPN's safety protocols. If it just forwards anything that comes its way back your way, you're fine. If it wants you to open ports and such as that and only forward certain things, then you're screwed unless you jump through their hoops and allow the transfer. My advice here: Use your actual web address. 172.83.131.239 happens to be my permanent little home on the web. From time to time, I tend to host my own website, and I need a static IP so I can always connect to it when it's up and going. Most folks have a dynamic IP, which is assigned to them randomly every time they connect to the internet (it costs extra $$ each month for a static IP), so you'll need to update your chat program with the current IP with each reboot of your computer. Once you've gotten your IP address, you can now go into the code above and make the drastic change from local to www connections: Code: (Select All) client = _OpenClient("TCP/IP:7319:localhost") Change the line above to where it now has your IP address, rather than "localhost". Code: (Select All) client = _OpenClient("TCP/IP:7319:172.83.131.239") ^That's what it'll look like for me. For you, the same, except with a different IP address in there. And that's basically the ONLY TCP/IP requirement that QB64-PE makes you have to change to make it work and communicate across the net! And chances are, if some of you try to make that work, it's not going to work for you. In fact, I'd bet against it. WHY?? First is the TCP/IP:7319... What the heck is that 7319, and why is it in there? It's one of the multitude of ports which our modern PCs have available for us to use to communicate with things. How was 7319 chosen? That was all just Steve, picking an unused port on my PC, and deciding, "I'm ah gonna use dis one!" Most of the time, our modern routers tend to lock down port access for most people and things. You have one or two ports open for common stuff (like http and https transfers), but the rest of those ports are locked for security purposes. Since there's a zillion different routers, and a zillion different ways they're configured, with a zillion different sets of software to interact with them, *I CAN'T HELP YOU WITH YOUR ROUTER SETTINGS.* You'll have to Google, dig out the manual that came packaged when you bought the router, or call your ISP and ask them to help. At the end of the day though, you're NOT going to be able to share communications unless you're sharing on a port that's opened and allows it. <--This part, unfortunately, you're on your own to puzzle out. All I can say is "Open your router settings, choose a port you like that's not currently in use, and open it -- however you do that on your router." Once you've got an open port, and if it's not 7319 like I chose for it to be, then you'd need to change your program to work on the port you've chosen. Code: (Select All) client = _OpenClient("TCP/IP:####:172.83.131.239") Try that, and it MAY work for you. Once again, however, I'd be willing to bet against it. Once more, go into your router settings, and this time look for PORT FORWARDING. Most of us have multiple devices set up for the internet. Our phones are connected, as is our pc, our ipad, our tv, all our damn smart lightbulbs... You probably need to do a little more specific directing with port forwarding to tell your router where you want to send that open port information to. Once again, I'm sorry, but I can't really help much with this step as every router has it's own software and way of interacting with you. Click on the image above, if you want, and it'll show my router's port forwarding setup. The first three and where I host my own private server from time to time (ports 80 and 443 and http and https traffic, while 3306 is where my SQL Database likes to communicate back and forth when it's up and running). The last entry in that list, however, is the one of interest for you guys -- Laptop Forwarding on port 7319, and which is going to 10.243.1.77... That 10.242.1.77 is my laptop's local address on my network. By setting up port forwarding like this, communications on port 7319 are now routed directly to it, allowing it to communicate with the rest of the world. Once you've set up the open port, and forwarded it to your machine which is going to run the compiled EXE, chances are you're good to go!! Your firewall might pop up a question "Do you really want to allow this", but you can feel free to tell it to pisser off. You've got to let the information travel back and forth to your PC, or else you'll never be able to communicate on an open port like this with the outside world. So you run it... And it works!! YAAAAAAYYYY!!! You go to bed, get up the next morning, notice that Windows did an update on you, and it now no longer works. WTF?!! (I can just hear some of you cussing already! No worries -- no judgement. I've been there as well!!) Two important things to keep in mind: 1) If you don't have a permanent STATIC IP address (you'll know if you do because you asked for it specifically from your ISP and are paying extra each month for it), then your IP address is dynamically allocated for you. You'll need to get the new address, swap it into your program, and try it again. 2) And if number one doesn't fix the issue, problem number two is... dum dum de dum... once again dynamic addresses. That last step that we did, with the port forwarding... Remember it? You forwarded your data to a specific local IP address... If you don't have that configured as a static address (set up manually instead of automatic), then it may not be the same as it was before either. You may have to go back and change your port forwarding address once again so it works as you'd expect. RE: Chat with Me -- HOST - SMcNeill - 12-11-2022 And, with all that said and posted, here's what I'd recommend: If you're just going to play around a few times to test the capabilities and learn about things, then don't worry about STATIC vs DYNAMIC stuff. Set it up, make the few changes needed, get used to your router and interacting with it, and just swap those addresses as needed. IF you're going to be using the same program repeatedly, however, and you don't want to have to jump through an endless set of hoops, call up your ISP and tell them to swap you over to a STATIC address. Mine costs me an extra $5.00 per month, and it's worth that little amount extra, just to save me the headache and trouble of having to change numbers after each reboot or update. As for the local setting for your PC, those you can configure yourself for no extra cost or anything. It just takes a little time to tell Windows (or Linux/Mac as your device dictates) to always connect this computer as 10.243.1.77 (or whatever you specifically want it to be.) Serious web hosting should be done across static connections. It'll save you a ton of troubleshooting, compared to having to always redo your dynamic setup with each run of the software/reboot of the system. EDIT: https://www.onmsft.com/how-to/how-and-why-to-set-a-static-ip-address-in-windows-10 <-- Link to configuring windows to use a STATIC IP locally for your PC/laptop, so it doesn't change with each reboot. (Step 2 with port forwarding that I addressed; not step 1 -- find your internet address. This is for a static local address. You'll need your ISP to give you a static web address.) RE: Chat with Me -- HOST - Pete - 12-11-2022 Find your IP4 Address for Windows systems. (See the caution at the top of the code). Edit: There may be a language difference that prevents the search match. The routine is not case-sensitive, but see, "search$= " for supported search terms. Code: (Select All) ' CAUTION - THE SHELL STATEMENT WILL OVERWRITE ANY PREEXISTING FILE YOU HAVE IN YOUR LOCAL DIRECTORY NAMED "tmp.tmp". Pete RE: Chat with Me -- HOST - Kernelpanic - 12-11-2022 The file is created, but is it by design that the output doesn't appear on the console? RE: Chat with Me -- HOST - Pete - 12-11-2022 (12-11-2022, 06:02 PM)Kernelpanic Wrote: The file is created, but is it by design that the output doesn't appear on the console? The output should appear. It does on mine. Let's do this. ------> I edited the above code to search for both IPv4 Address and IP Address. 1) Open the tmp.tmp file in Notepad and look for... IPv4 Address IPv4 (space) Address. It doesn't matter what the case is, upper, lower, mixed. If it isn't there, I'll bet you don't have network on a wireless router, or it is being reported as IP Address, or something similar. So let me know, and if others are not getting an output, please post either the tmp file, if you don't mind giving out your personal info, or how it is configured, whatever we can be used so we can get an automated method to assign the IP address. Thanks, Pete RE: Chat with Me -- HOST - Kernelpanic - 12-11-2022 Nothing is displayed for the changed file. The tmp.one and tmp.two files are identical. With tmp.one-n, only the IPv4 address has been made unrecognizable. Code: (Select All) ' CAUTION - THE SHELL STATEMENT WILL OVERWRITE ANY PREEXISTING FILE YOU HAVE IN YOUR LOCAL DIRECTORY NAMED "tmp.tmp". Code: (Select All) Windows-IP-Konfiguration RE: Chat with Me -- HOST - SMcNeill - 12-11-2022 @Kernalpanic -- it's your language and the search term: search$ = "ip address" vs "IPv4-Adresse" It's not printing anything simply because the search isn't matching and finding anything to report back for you. Not that I'm even certain how the heck you'd get a 192.---.---.- address. Is that something with the virtual machine itself? Or did you edit the output to protect your address yourself? Those dashes are new to me. RE: Chat with Me -- HOST - Kernelpanic - 12-11-2022 (12-11-2022, 08:26 PM)SMcNeill Wrote: @Kernalpanic -- it's your language and the search term: search$ = "ip address" vs "IPv4-Adresse" The dashes are mine. A dash for each number. There is a full IPv4 address. PS: The Virtual Box: This is the installed Oracle Virtual Box. RE: Chat with Me -- HOST - SMcNeill - 12-11-2022 (12-11-2022, 08:47 PM)Kernelpanic Wrote:(12-11-2022, 08:26 PM)SMcNeill Wrote: @Kernalpanic -- it's your language and the search term: search$ = "ip address" vs "IPv4-Adresse" I was wondering! The only time I've ever seen dashes in an IP address was when it was a range of addresses assigned to someone. 123.45.678.90-9 <-- this means that all numbers from 123.45.678.90 to 123.45.678.99 are all assigned to the same person. And honestly, I think I've only ever seen that type of format once or twice in my illustrious hobbyist carrier as a programmer. RE: Chat with Me -- HOST - Kernelpanic - 12-11-2022 (12-11-2022, 08:55 PM)SMcNeill Wrote:(12-11-2022, 08:47 PM)Kernelpanic Wrote:(12-11-2022, 08:26 PM)SMcNeill Wrote: @Kernalpanic -- it's your language and the search term: search$ = "ip address" vs "IPv4-Adresse" I hardly know anything about TCP/IP anymore. I was busy with it once: TCP/IP for Dummies from 1998, as I just saw. |