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 / What's My IP? Why Am I Asking You?

Author
Message
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 2nd Jun 2007 04:31 Edited at: 2nd Jun 2007 10:21
...when I can ask Windows directly?


.
El Goorf
17
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Uni: Manchester, Home: Dunstable
Posted: 2nd Jun 2007 12:04
i dunno, why are you asking us when you can ask windows directly...?

http://notmybase.com
All my base are not belong to anyone.
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 2nd Jun 2007 18:42
he's not asking he's telling you how to find your pc's ip in dbpro.

new learning center comming soon http://911.bounceme.net/
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 2nd Jun 2007 23:05 Edited at: 2nd Jun 2007 23:06
...here is a clearer and more stealable version. I don't think I can hold my own hand any more than this one does. If it fails, I think your program is already in the tank.

Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 3rd Jun 2007 01:18
i dont belive it looks like DBP code..
and i think that only DBP help is here..
as it says on the forum topic: DarkBASIC Pro ONLY

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd Jun 2007 04:06
Are you ok, Sergey K?

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 3rd Jun 2007 05:46
I believe he was getting confused by seeing.



I guess it's nice code but you may want to make it into functions that people can easily use, most users won't know what pointers or bitwize operators are.

Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 3rd Jun 2007 05:48 Edited at: 3rd Jun 2007 05:49
Lol bro, did you even try running it in Dark Basic Pro? It may look alien to you because it calls dll functions, concatenates strings, uses local variables, and uses many pointers. It's very well programmed in Dbpro.

Edit:
Didn't see the first example, a little odd with the use of the '{' but compile it first lol... It won't run most likely unless you fill the '...' with your info.


z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 3rd Jun 2007 06:41
Nice code there. It could sure come in handy someday.

Intel Core 2 Duo 6600 2GB DDR2 RAM Radeon X1600 Series Realtek Sound System

Persist and you will succeed.
Vampiric
17
Years of Service
User Offline
Joined: 30th Oct 2006
Location:
Posted: 3rd Jun 2007 15:27
Great bit of code you've got there.

Computer says n00bed
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 3rd Jun 2007 16:27 Edited at: 3rd Jun 2007 17:08
@Vampiric, z_man, etc. : thanks, I am writing a Telnet client and server using Multisync. I plan to use Tempest, as well. This will give both TCP for connection, and UDP for passing game info. There is a purpose to it, you will see....
@dark coder...you mean like the second, more clear, more stealable version? I put the first one in with alot of comments. You are supposed to study it and learn from it. The C typedefs are embedded in comments, but you probably did not run it, otherwise you'd have seen that. Actually, that is in a separate file; I use multiple sources. Part of a plan.
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 3rd Jun 2007 22:08
@Sergey K: It is dbpro code i tested it to see.

new learning center comming soon http://911.bounceme.net/
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 3rd Jun 2007 22:20 Edited at: 3rd Jun 2007 22:29
Quote: "@dark coder...you mean like the second, more clear, more stealable version? I put the first one in with alot of comments. You are supposed to study it and learn from it. The C typedefs are embedded in comments, but you probably did not run it, otherwise you'd have seen that. Actually, that is in a separate file; I use multiple sources. Part of a plan."


Huh? I was pointing out to Sergy that they were comments. I wasn't wondering why they were there, Also I didn't need to run the code to see what it does.

Furthermore I don't require this code, I'm saying that the average Joe user doesn't want to learn how these things are done, if you package it into some nice and easy to use functions it's like having Jinzai on your team . Plus getting a user's IP address isn't a particularly hard thing to do (code structure/implementation wise) so even if a user were to study your code and make their own implementation it would likely end up being the exact same.

LongFist
19
Years of Service
User Offline
Joined: 25th May 2004
Location: Winston-Salem, NC
Posted: 4th Jun 2007 17:48
And if you're in a pinch, the Enhancements Expansion Pack contains the easily-referenced
Quote: "return string = GET IP ADDRESS$()"


...but what I'm after is a method of figuring out whether or not your code is running on a machine connected to a router, and if so, get the router's IP address! All of these other methods make the call to your Windows networking layer, and gently request the IP address from there - but you won't be able to reach me from "out there" hacking at 192.115.7.101, now are you?

LongFist
SuperProgrammer For Hire
Turoid
20
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 4th Jun 2007 18:23
Quote: "And if you're in a pinch, the Enhancements Expansion Pack contains the easily-referenced"


Hahahah! sorry.. found that very funny

I am awesome and always right.
LongFist
19
Years of Service
User Offline
Joined: 25th May 2004
Location: Winston-Salem, NC
Posted: 4th Jun 2007 18:48
Quote: "found that very funny"


Me too, really. Hard to make jokes like that, and get away with it...

LongFist
SuperProgrammer For Hire
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2007 07:41 Edited at: 5th Jun 2007 09:40
If the address returned is part of the private address pool, you are behind a router. 192.168.n.n, for example. The code posted does that already. Look at the structures, and what they contain. I put that in there for a reason.

Yes, that function call will return the default IP, but that is all. My code returns alot more than an IP, and iphlpapi.dll does alot more. This thread is about alot more than finding an IP. Nice burn, however.)
Here is something from the Platform SDK that might make things a little clearer:



You can usually substitute the address "0.0.0.0" anyway. There is no need for a client to ever know their own IP.



You use the address that belongs to the machine...you can't use any other. The packets come back to the router, and port forwarding sends them to your machine. The Internet IP belongs to the router. Beyond getting that, you need to sit your server on the modem itself. This step is not nearly as trivial as all of that. There is more to it than code. Money, for example.

For the record, this code is placed here for people to use. If it doesn't work, I have no problem with you critiquing it. I have zero ego invested in any of this; quite the contrary. I paid for DBPro, and I have posted literally thousands of lines of code here for free. I have never once hawked anything.

The intent of this thread was to start a HELPFUL DIALOG with respect to large scale Internet communications. If that is not your aim, start your own thread. Don't post in mine.
LongFist
19
Years of Service
User Offline
Joined: 25th May 2004
Location: Winston-Salem, NC
Posted: 5th Jun 2007 15:24
Quote: "The intent of this thread was to start a HELPFUL DIALOG with respect to large scale Internet communications. If that is not your aim, start your own thread. Don't post in mine."


Oops! Hey Jinzai - I would never be critical of such a productive and helpful member of the forums as you! In fact, I go out of my way not to be critical or degrading to anyone in the forums. Guess that makes me pretty spineless, where the 1337 are concerned. But I think you misunderstand me. (Not surprising, as my posts (after the first) aren't all that clear: I was just having fun.)

I merely pointed out that I was looking for a feature/function/whatever that could "auto-magically" sense the [computer-modem/computer-router/computer-connection] situation, maybe by checking to see if the computer was using a Class C network address (or not), and if so, determine what the router's IP address was, and reflect both the *inside* and *outside* IP addresses to the user, preferrably during "Network Game Setup".

Quote: "You use the address that belongs to the machine...you can't use any other."


Sure. If you all go to the same side of the firewall/router to play. But what if player OmegaFlux wants to join in the game that you're hosting, and he's in another city? Or what if you want to join a game that someone else (somewhere else) is hosting? The 'Net makes all of that possible, but you have to know a few things first. Inevitably, you'll need to know your portal's IP address - the addy of your router, dsl modem, cable modem, or provider's connection (if you're still dailing up) in order to make that connection. And one of the most annoying answers to the question "Hey, what's your IP?" is "um, 192.168.1.100" - which he's reading right off the "Network Setup" tab, under "IP Address". A quick trip to [http://www.whatsmyip.org/] and my would-be game host has better info, and we can connect and get down to things that go fast and blow up.

Eventually, when I get the time (famous last words!), I'm going to figure out *exactly* what is required to get those IP Addys, one local (because you generally use the IP address assigned to your machine) and one remote (because sometimes you end up playing host to players outside your firewall), and provided them both to the end-user (player, host, whatever) for his/her/its enlightenment. Maybe with a tile underneath each saying "Local: for players inside your network" and "Remote: for people 'out there' on the 'Net" or something - I haven't figured out exactly what it should say - but it should include the port addresses for outside use as well, so the host player doesn't need to go searching through a stack of manuals or hit the 'net just to find out what they are. Just my goal, it's what I'm shooting for.

--- Currently, I have a kludge, embarassingly simple - it does a quick check run to http://www.whatsmyip.org/ and gathers the first few lines after the html header. I then isolates the IP address, and compares it to the local one. If they're different, two IP addresses get shown, and the port list as well, just in case... ...but it's such a kludge! What happens if http://www.whatsmyip.org/ goes down, goes away, or changes places? It kills that "remote" IP address ability, leaving the user pretty much on his/her/its own again. I've just gotta' find a better way. I've just gotta...

LongFist
SuperProgrammer For Hire
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2007 18:31 Edited at: 5th Jun 2007 18:43
That post was only saying, let's stay focused on the prize. That post of yours states it all better than I ever could. T H A N K S. you have listed the situation perfectly imo. My code only starts that process. DirectPlay gives you scant little control, and yes...everyone needs to be in the private LAN...it uses IPX broadcast, others already figured that part out. So, what to do? Let's all find out. I am copying what others have done in the past, it starts with Telnet.

http://en.wikipedia.org/wiki/TELNET

Obviously, clarity is one of my problems, too. This stuff is complex. It is a real shame when we bicker instead of coding. If it moves things along, I will break a few eggs. It is never my intent to seem pompous, but that is more of a limitation of the medium than me overstating my capabilities, or disregarding the capabilities of others. It is perfectly understandable when people think that of me; I don't mind being challenged or called out outright. I get better in the process, too.

The last bit is not directed at anyone in particular. (Honestly, dark coder, it is not to you. I understand your objections, but all that means is, like you said, you don't require this code. That's okay, you already have network code. I know that already, too.)

The main thing I want to make clear is that my code will return IPs for more than one network adapter. The situation of placing a PC on the modem so that it receives an Internet IP is a valid (and invalid in some cases) method to get served yourself. It can't be used to host substantial games because (my) ISPs don't allow that. When you start using alot of bandwidth, they will likely have a problem with that. However, you can write servers for alot of the TCP protocols. That is why I suggest you Wiki TCP Ports.

http://en.wikipedia.org/wiki/Standard_TCP/IP_Port

You will get a list of most major Unix apps. I have mentioned Telnet, It is a vital component of major online efforts. I have a very thin client and server written using Multisync. They are not quite ready for posting, but so far:
The server will configure Multisync to use port 23, which is Telnet default. The server then waits for a connect request. Then, the server spits out its name, and a challenge. The client then does its logon. My code has it hardwired, but it will either use text, like Telnet would, or perhaps a Windows dialog. Then, code derived from it could verify the account, and start the process of putting the client into the game. That involves UDP, I will need Tempest for that, or maybe something else. I don't know Tempest well enough to say. The example in Multisync...the first one, I mean. It implements a complete game interface; its very thorough for a piece of boilerplate code. I have written what I mentioned using the same type of command interface. This will be clear when I post the code.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 5th Jun 2007 20:16 Edited at: 5th Jun 2007 20:24
LongFist, I do not want to post this in your thread, so I will continue our dialog here. I hope that you understand my intent.
Here is another bit from Microsoft, this time it is from VisualC++, but it is also in the Platform SDK:



In VB, you probably were using the MFC class; they are exposed to VB as well as C++. MFC is great, but I have not attempted to spin that up; it is generally overkill for what we are doing here, I think. Also, there is GET/POST. That could be used to pass small bits of info, but it is still tied to the retrieval of HTTP. HTTP is TCP port 80. You can use it in your own way, but there are also Unix methods like finger and whois. The problem with that is that is assumes your server's presence is legitimate. (i.e. you can use DNS to find the IP.)

The nature of this is that we all butt our heads against two things:
incomplete understanding of the "problem", and our ISP's legitimate efforts to prevent people from stealing bandwidth with strange and often faulted network apps.
LongFist
19
Years of Service
User Offline
Joined: 25th May 2004
Location: Winston-Salem, NC
Posted: 5th Jun 2007 23:12
Most humble Thanks, Jinzai. I started the new thread because <a> you started me thinking about that kludge, and how I might possibly make it better (a common theme among the truly elite, here), and (more importantly) <b> I didn't want to hijack your thread with a subject that was kinda' on track, but far enough off to be considered rude to you. As I said before --- I try to avoid intentionally ticking anyone off here in the Forums. However, sometimes my ADHD (coupled with lack of sleep) gets the better of me, and I stomp on toes better than a frightened elephant in a crowd of pygmies...

LongFist
SuperProgrammer For Hire
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 6th Jun 2007 00:08 Edited at: 6th Jun 2007 02:29
Oh, we are in total lockstep, here...no worries. You could make an html page that only passed the dynamic IP. It could be anywhere, (even as a legitimate clickable link.) or you could use GET/POST to send the string, ready to go. In other words, you could use redirection of some sort. You could also update the page's link as the IP changed. Again, this is a sticky wicket from the standpoint of your ISP, but you could present a remote app to users that way. There isn't any real magic available that will allow someone to host WOW on their Mom's work laptop, that is a myth. (Linux would be a good place to start down that rabbit hole, but not Windows!) We do have an excellent glue language in DBPro, however. That is enough for legitmate use by the likes of us, I think.



I hope that works!
EDIT: Okay, let's go ahead and work that up, LongFist. I mean, let's go ahead and use WinInet from DBPro. I only have a little experience with this API, and that was using MFC. I will attempt to write a bit of code that will grab the IP from that html bit above. I don't think you are kludging at all, btw...just doing what you gotta do. It should only take a few function calls, WinInet is actually pretty cool. Oh, wait...need HTTPAPI, too. I have that snippet sitting here:
http://geocities.com/mtb61275/dbpro/test.htm
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 6th Jun 2007 18:00
Quote: "most users won't know what pointers or bitwize operators are"


I just skipped down to post..(probably my first post in this board in a year!)

actually, most programmers really should know, it doesn't matter if your just doing game stuff...trust me, You about can't live without them in some spots..

for bitwise, I almost guarantee it is quicker to make your own shifts such to make an RGB value from the r and g and b variables than to use that one RGB function included in dbp..

pointers, you just should know! If stronger pointer support was implemented, it'd be a piece of cake passing user types to functions....but meh...just my bit of a rant..(maybe theres a reason I don't post in this board..lol)

Open86 --My Emulator (now with it's first super alpha release
I'm addicted to placebo's...I would quit but it wouldn't mean anything! lol
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 6th Jun 2007 19:02
I appreciate you using your annual post to point that out. I thought it was a little more obvious than that. I had hoped that the comments in the first post would help demystify some of it. Yes, I have been whining about pointers, callbacks, and addressof. It is BASIC, and my BASIC programming is starting to look too much like C++, but that is good.

I would also expect independently developed code to look very similar, but that makes my point, as well. The code I am now working on is similar to what spooky referred to, but it works a little differently that that code. This is because of my geocities account, I think.

I have written the code to get the web snippet from my geocities account. Tonight, I will write some code to parse the IP from the three places I mentioned above. I was unable to get geocities to send the file length, and the query to get the title was similarly unsuccessul. Both are either my incompetence (there are some options along the way to downloading HTTP), or Yahoo not wanting to support my shenanigans. Either way, I got the file! I will use the code to go back and see exactly what my free website is delivering. I can already use it to publish my server's IP, and also have code that will get that IP automatically.

It seems over the top for a reason. That reason has nothing to do with DBPro, or really anyone's programming skill. This programming paradigm is global in scope...literally. It should not surprise anyone that the code is onerous and complex. Also, TCP/IP is still very new to the Windows system. It is a very complex system.

There is an opportunity here to explore an huge and often frustrating aspect of DBPro application development. If someone does not understand a concept involved, and I can help them gain understanding, then I have met my goal.

I will hopefully post some more code tonight. Also, I want to begin some discussion of real-world network setups. I already mentioned multiple adapters, but I thought that anyone with multiple adapters already knew about the IP Helper utility. It seems like most people sit just behind a router like me. I have only 1 system, so my options are limited.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 7th Jun 2007 19:20 Edited at: 7th Jun 2007 19:47
Update: I did not parse the string last night, I was wiped out from work. What I did do today is to start a project to provide some code that is not tied to my own system too much. It has been correctly pointed out that networking has to be fitted into the application at hand. "Team jinzai" is well aware of that, and I have started a project that can be made into a nice network utility while not violating my ISP agreement.

The snippet that follows will initialize WinInet and get a html page from my free Geocities account. That account is typical of free accounts in that they encase your HTML in a Javascript page, so it will contain alot of ads, icons, etc. Also, it does not get sent out like a straight HTML page, and the server is not guaranteed to provide any extra information about it. I have modified the code that has been used in the past for this purpose. The receive routine is not exactly robust. Basically, I give it a 32K buffer, and hope for the best. Ultimately, that is not acceptable because it either wastes memory or will fail to receive the file in its entirety. That requires more involved and specific stuff. You might not want that, so...feel free to modify it to suit your needs.



I had originally intended to use the more capable WinHTTP API, but I discovered a big problem with that. Alot of developers have lost the include file for it because of how MS updates their stuff. I was able to load the dll fine, but when I went to get all of the pertinent info to use it, I could not find it anywhere. A quick search showed me page after page of people trying to find it. I downloaded the latest Windows Server 2003 SDK update, and got it from there. It is a little hard to find! Anyway, I will also code up a DBPro interface for that one. WinInet is very good, it also does gopher and ftp, it does not do IPV6, however. (But IPV6 is not as universally applied as it was supposed to be anyway.)

This will ultimately be serverless, but that is not to say that it is peer to peer. The server will be distributed; we are not going to violate the ISP agreement as I understand it, and we will be playing games across continents.
LongFist
19
Years of Service
User Offline
Joined: 25th May 2004
Location: Winston-Salem, NC
Posted: 7th Jun 2007 19:41
Hey Jinzai - I'm just about finished with the "External IP Grabber" code. I just haven't parsed the IP address out of the deluge of HTML that it (necessarily) is hopelessly snarled in. I can't thank Spooky nearly enough for his help and support - he answered my question here perfectly, and as a direct result I've only got to get enoughtime (at one sitting) to figure out the quickest way to parse the IP Address out of all of that HTML - not an easy task, when it's supposed to be flexible enough to "read" from many different "free" 'This is your IP Address' web pages.

I just need to get a little more time at one sitting. Naturally, I ripped your module (at the start of this thread) to report the internal IP Addresses, sans "invalid entries". With full due credit, of course. The result will be a single module that - when it's called - will report your local IP Address(es), and your external (connection) IP Address (if it's different). And with *no* kludge files to work with! Yayyy!

I have, however, encountered a problem of ethics: while I am testing this module against the various free "This is your IP: xxx.xxx.xxx.xx" web pages, it should not really be deployed that way. The responsible coder - responsible for keeping the game "together" and net-workable - would need to build a web page somewhere that did nothing but return the caller's IP address. That would be the responsible thing to do. But I wanted this code to work right now, so I'm making it possible to dig out the end-user's external IP address from the free-use IP reporters.

If I post this coded with that capability, it is a surety that the munchkins and such will use it "as is", and ruin yet another good (free) resource on the 'net. Repeatedly hitting a "WhoAmI" site will use a lot of their bandwidth, causing them to take steps.

So - what should I do? Continue on, steal some time, and finish the free-IP parser to illustrate how handy this thing can be - or figure out where there might already be a server that returns just the IP address, forego the parser, and release it "as is"?

Just thought I might give us something else to debate.

LongFist
SuperProgrammer For Hire
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 7th Jun 2007 19:53 Edited at: 7th Jun 2007 20:03
Which is the other reason why people don't post in this thread. I had to go a different route in my version of this. You will see this project take some very sharp turns It will be legal and you will not be able to take pieces of it, and make an illegal setup.

In the end, the hacker will fail anyway. Like I said, you can't masquerade an IP for example...the underlying TCP/IP stack will disallow it. Also, Geocities has protection, too. Finally, the ISP will not let you ftp out, or any of that...there is a reason why the ports exposed by DirectPlay are in the "I don't care" region. I have no worries about how my code is being used. A person can only do what is possible within the framework they are given. We can, however define a multicast UDP group and send stuff to each other. This requires one player with a legal ftp capability, which is not hard to muster up.

btw, the method you have proposed is, I think how it is done anyway. Guy goes to HTML page, presses button, "Host Game", then the game shows up on HTML page. Players press "Join Game"...like that? Okay, let's do it that way, then.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 8th Jun 2007 02:31
Okay, I have no more time for this today, so here is the client side of what we are discussing. I cheated and used C for the string compare because it is perfect for this.

Login to post a reply

Server time is: 2024-05-04 16:35:13
Your offset time is: 2024-05-04 16:35:13