Get my Game Maker On

Posted by Toon-Master on Nov. 7, 2006, 8:13 a.m.

Heh as you notice, "Get your game on" is still in my head. I think I'm starting to like that line too. Also "Throw Down" is in my head…


Get my Game Maker on - UDP Broadcast


Well today and a bit of yesterday I started trying to learn how broadcasting works. I said to myself, "I don't have a network anyway…". But then I relise I could just use local host (hopefully)… I'm sure sending a UDP message with a broadcast address would send it to myself.

I only started this because my last blog had a comment from Evilish to tell me to make a UDP broadcast tutorial as a suggestion. And I said broadcasting was evil because it creates a load on the computers. Although he already made one, his had problems. So I just went to learn a bit of broadcasting (to find his problem) from Google and Winsock FAQs and found lots of interesting stuff.

So I decided to make an example of it (time to throw down GML). You can get the example at the bottom of my blog. Firstly I was WTF on how to get the subnet broadcast address. I was so close to saying, "Stuff it, use". Lucky I saw Winsock FAQs about broadcasting. It was somewhat using an internal IP address. You could use mplay_ipaddress(); or in 39dll hostip(myhost()); to get the address. And you needed the subnet mask (well in FAQs it was lan netmask). I was stuck and still am, so I just assume it was subnet mask. I didn't know how to get such a address… So I knew one way, which was the ipconfig in the command prompt. I guess I needed that Slient Dos DLL (DLL made by TGMG), so it gets the contents. There was probably a better way to do it, if I had the brains. And then it uses those 2 address with some bit wise AND, NOT and OR to get the broadcast address.

Well I think that was the hard part. So I just placed all the stuff to do with broadcast. It isn't had to send a UDP message, just needed the address. The 39dll function lastip() is very handy because it returns the IP address of the last received UDP message or last accepted socket with tcpaccept();

And the list of IP addresses were just stored in a Data Structure lists, because I wanted to clear the list incase the server did not exist or just refreshing.

To finish off the example, I just throw down a 2 player TCP walk example. And I must say, I need to start working on more experiments and games (that esspecially).

Anyway, Evilish's tutorial was errored. I should point out to you for anyone's learning purposes (no offending here). Actually I'll just say the main one. The reason why he received the message twice was when he broadcast, he got the message twice. It happened by sending the UDP message with the actual IP address and send the same message with the broadcast address (send a message to all addresses).




Download: UDP Broadcast Example

You probably wonder why I'm telling this. Well I need to get my facts right. Also I don't have a network going about, so I need some people to test it to trace errors. I'm going to try tommorow in college though.

I tested myself with success, because I can not run the server and run the client to detect if a server is availible. And if I run the server I can hit refresh and see my Internal IP address there.

Oh if you heard about Bullnet, I never followed it that way… Why because the x.255.255.255 wasn't a good idea. I wanted it to be in 1 subnet area or network area(I think that's what it's called).

That's all

- Toon-Master

EDIT: Hmm netmask in college is too. Now testing…

Alright did a test, I got to fix the way it tries to get the subnet mask. I should add the default subnet. Incase it didn't work. Such as now… (changes temp_directory to nothing).

Yay it works.


Flea1991 13 years, 8 months ago

Good-luck. [:)]

Toon-Master 13 years, 8 months ago

LOL that was fast. Thanks

- Toon-Master

basilamer 13 years, 8 months ago

Sounds cool!

Evilish 13 years, 8 months ago

Another thing is that command prompt is blocked at my school, which means that your example wouldn't exactly work there would it.

Eh, idk, seems like a lot of work you did, when the only real error in my script was the thing…

Arcalyth 13 years, 8 months ago

I wonder if its possible to send a message to everyone on the internet.

Toon-Master 13 years, 8 months ago

Yeah there was only 1 error, and just there was alternative stuff you could do like use lastip(); But oh well.

I don't have to use the command prompt if I don't want to. I could always just assume the netmask is or something along (depending on Class type) meaning I don't have to do that bit wise operators to get the IP address and do what you did.

Hmm send a message to everyone to the internet, truely evil.

- Toon-Master

Evilish 13 years, 8 months ago

It's pretty easy, but on what port would everyone be listening…

and then to sent to every port in the world is just… true evil

Toon-Master 13 years, 8 months ago

World Domination, would you say?

- Toon-Master

s 12 years, 10 months ago

The lag to be going through IPaddrs systematically would be horrid,with many computers offline and all