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.

AppGameKit Studio Chat / Tutorial & Guide for Multiplayer Socket...

Author
Message
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 20th Aug 2021 09:13 Edited at: 22nd Aug 2021 06:08
The only tutorial in AppGameKit document is for network, not socket...
Does anyone has a guide for sockets instead?

Any help appreciated!

UPDATE:

I have added the following code, but nothing works...

Client:


Server:
TamBam
12
Years of Service
User Offline
Joined: 29th Nov 2011
Location: India
Posted: 25th Aug 2021 20:45
You have no idea dear why socket programming need in app game kit. Main concept is if you make a program in agk and want to sent or receive data from other language like socket php,nodejs etc then we need socket programming. If you want server and client both written in agk then no need socket programming to write.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 26th Aug 2021 13:57
Sockets work fine



Remember you HAVE to setup the "Listener" to establish the "Server" Connection prior to attempting to Connect to the Socket.
Also keep in mind that a Socket / Listener ID MUST be a value between 1 - 4,294,967,295., although I'd always recommend letting AppGameKit assign this number; as some of it's functions actually require you to Create and Destroy ID's in order... so it's a good habit to just let AppGameKit handle assignment, that way it only fails when you run out of available IDs.

Also... 127.0.0.1 is a reserved IP., this means Local Machine.
If you want to access another machine on your Network., typically 168.192.xxx.xxx is used for a Local Network; while discovering what an Internet IP is., well that'll take a bit more work.

For example this Computer is:
127.0.0.1 (Local Machine)
168.192.0.202 (Local Area)
82.14.205.123 (Internet IP)

Although keep in mind., the Internet IP (on IPv4) is not Unique for each Device; it's actually the Router/Modem IP... and so if you have Multiple Devices connecting via such., they will each have a Unique ID... I actually would recommend using the MAC (Media Access Control) Address for IDs., as these are Unique Identifiers for said Device' Network Connection.
Now something I wish that AppGameKit did better was allow you to define a Range of Ports with a Single Connection.

What I mean is... just using a Single Port is going to be a problem when you want more than 1 Devices on the same IP to Connect., as this can potentially prevent connections.
Ideally you'll want an additional Port for each Potential Client in a given Server; as they could all be behind a NAT, and to prevent NAT Conflicts; you'll want them each to use their own Port.

You can do this via storing the ListenerID within an Array., and using a For...Next or Repeat...Until to set them up.
Oh and don't remember to also CLOSE the Connections. AppGameKit does a good job of closing / deleting things on exit., but it's a good habit to get into to clean things up yourself.
Esp. if you later plan to learn things like C/C++ where the language DOES NOT clean up after you.
stigmat
5
Years of Service
User Offline
Joined: 1st Apr 2019
Location:
Posted: 27th Aug 2021 17:01
Thank raven for this post.i take it for stud it

Login to post a reply

Server time is: 2024-04-18 04:23:30
Your offset time is: 2024-04-18 04:23:30