Jump to content


Photo

Gmsock Threaded - Highspeed Online Extension


  • Please log in to reply
104 replies to this topic

#1 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 11 September 2005 - 08:35 PM

GMsock threaded, as you probably know, is an extension for Gamemaker allowing you to utilize sockets. With its combination of raw socket power, with the multi-threaded design, you have a socket library rivaling that which commercial games utilize, in a simpler package.

Since I don't have a help file yet, I'll try to compensate with this FAQ.

Q: What does multi-threaded actually mean?
A: Your computer splits up multiple tasks into independent threads, or segments of code that run simultaneously. That’s why you can be browsing the web at the same time your music player can play music, for example. Two tasks at one time.

Gmsock utilizes the same technique, liberating socket handling code from GMs thread. This leaves GMs thread free to do the important part: Run the game. Previously, a laggy connection meant a laggy framerate. Not any more! Since GMsock threaded runs in a separate thread, the slow network doesn't bog down the actual game.

Q: What’s the difference between TCP and UDP?
A: TCP stands for transmission control protocol. TCP best parallel a phone. You call someone, exchange data (or for your normal folks, chat :(), then hang up. TCP works the same way, by creating a virtual stream between two computers. The problem with TCP is that is tends to be slow. TCP utilizes several methods of insuring data integrity, or in laymen’s terms, making sure your data actually got to the other end. Thing is, most games don't need this. Will it kill you to have a player not in the exact correct place for one frame? Probably not.

UDP, on the other hand, is more akin to the postal system. You mail the letter, and bada-bing, bada-boom, go about your business. There’s no way of knowing if your letter got there, or even if it was corrupted during transit. The advantage is the go about your business part. UDP has a much lower overhead, or the amount of time it takes to actually send data. So UDP is usually the logical choice for high action games.

UDPs downside, however, is that it requires both ends to have a properly configured router and/or firewall, where as on TCP, only the hosting end must have it configured. That’s why most commercial MMORPGs use TCP, but cut corners elsewhere, like click to walk. It only needs to send one packet, where you clicked, so they can live with the overhead of TCP. But high action games like FPSes tend to use UDP, and That’s why they are so finicky about their routers.

Q: I think I found a bug. I'm now going to e-mail you my entire game, all the while spamming your screen name with "iT Don’t W0rK LOL WTF!!1!1!11"
A: *sigh*

Anyway, you can download GMsock Threaded 1.1 (build 521) here, or until my site is up, get it here

Matthewbot (aka, The Sock Master)

Unfortunately, due to time constraints and lack of interest, you can pretty much consider this project over. If I feel like it, I could help/explain a thing or two if you PM me, but I probably won't roll out any new versions, or make a tutorial/help file. You might be better off choosing another network DLL with better documentation that is still under active development.

Edited by matthewbot, 02 January 2006 - 02:20 PM.

  • 0

#2 Meiun

Meiun

    GMC Member

  • New Member
  • 248 posts

Posted 11 September 2005 - 10:12 PM

Very awesome! Gmsock has always been a top notch networking DLL, and this just makes it all the better.

Edited by Meiun, 11 September 2005 - 10:12 PM.

  • 0

#3 GmDude66

GmDude66

    GMC Member

  • New Member
  • 348 posts
  • Version:Unknown

Posted 11 September 2005 - 10:14 PM

Nice! I'll upgrade my game to GMsock 3 now =P.

~Derek~
  • 0

#4 DJ Gman

DJ Gman

    GMC Member

  • New Member
  • 685 posts

Posted 11 September 2005 - 11:09 PM

nice *waiting for explosion of new mmo's* :)
  • 0

#5 Cynical

Cynical

    Inside the Cynic

  • New Member
  • 423 posts

Posted 12 September 2005 - 01:17 AM

Nice work, just as the previous versions. I looked at the source and nearly died :) ...
  • 0

#6 GearGOD

GearGOD

    Deus Verus

  • GMC Member
  • 2153 posts

Posted 12 September 2005 - 01:20 AM

Strange, every MMO ive seen behind the scenes of, was built on top of UDP, and I never had problems with UDP games clientside with routers. Hosts, yes... Clients, no.
Perhaps I am mistaken?
  • 0
Engineers are not programmers. Stop thinking that you can save a few bucks by writing code yourself instead of hiring a programmer. Your code sucks.

#7 Heart_of_VVolverine

Heart_of_VVolverine

    GMC Member

  • New Member
  • 24 posts

Posted 12 September 2005 - 09:10 AM

DUde you RULLE!!!!!!!
i love this!!!
The help file that comes with 2.1c it's awsome... i can see it doesn't come with version 3 anymore :)

Keep up the good work! :) :P
  • 0

#8 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 12 September 2005 - 11:49 AM

Strange, every MMO ive seen behind the scenes of, was built on top of UDP, and I never had problems with UDP games clientside with routers. Hosts, yes... Clients, no.
Perhaps I am mistaken?

<{POST_SNAPBACK}>

Hmm, I'm not really sure. As far as I know, NAT routers block all UDP packets by default, except for really common things like DNS.

For everyone else, thanks for the replies! I'll try to write a help file if I can find time, but I've been really busy lately. Hopefully in a few days I'll have a more optimized version of it, there are some things I'd like to tweak a bit. I've discovered in some testing that critical sections, a way of keeping threads synchronized, is much faster than using mutex objects. By re-writing GMsock to use them, it could be considerably faster!

Edited by matthewbot, 12 September 2005 - 12:04 PM.

  • 0

#9 Degman

Degman

    There is no spoon

  • New Member
  • 263 posts

Posted 12 September 2005 - 02:19 PM

Strange, every MMO ive seen behind the scenes of, was built on top of UDP, and I never had problems with UDP games clientside with routers. Hosts, yes... Clients, no.
Perhaps I am mistaken?

<{POST_SNAPBACK}>

I'm very confused about this too, as it would seem most action games fundamentally require something as fast as UDP. I don't have a router, hub, switch, or external firewall, so I've never had to deal with those sort of client issues before. I will be getting a wireless router in the next week, so it had better be able to relay UDP :)

Ahhh GMsock..keep up the great work, matthewbot.
  • 0

#10 Bowex

Bowex

    Digital-X

  • New Member
  • 462 posts

Posted 12 September 2005 - 04:42 PM

it's finally done....great.... =))
  • 0

#11 Timmo

Timmo

    GMC Member

  • New Member
  • 558 posts
  • Version:GM:HTML5

Posted 12 September 2005 - 06:13 PM

Is this faster than earier versions?
  • 0

Posted Image Posted Image


#12 necromancer_productions

necromancer_productions

    GMC Member

  • New Member
  • 124 posts

Posted 12 September 2005 - 06:55 PM

Is this faster than earier versions?

<{POST_SNAPBACK}>


It is.

Shaya...
  • 0

#13 akimaru

akimaru

    GMC Member

  • New Member
  • 135 posts

Posted 12 September 2005 - 07:46 PM

wow this is great... replacing gmsock2 with 3 didn't cause any problems at all
since gmsock threaded is finally finished,
what are you going to do next?
  • 0

#14 arcooke

arcooke

    GMC Member

  • New Member
  • 1055 posts

Posted 12 September 2005 - 08:25 PM

This is great. Definately going to be a hit :)
  • 0

#15 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 12 September 2005 - 09:07 PM

New version released! GMsock threaded v3.1.0 is now out, and is much faster, having replaced mutexes with critical sections!

Edited by matthewbot, 12 September 2005 - 09:23 PM.

  • 0

#16 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 12 September 2005 - 09:17 PM

I don't see any manual to this? I thought I saw one before but were did it go?
  • 0

#17 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 12 September 2005 - 09:37 PM

I don't see any manual to this? I thought I saw one before but were did it go?

<{POST_SNAPBACK}>

Well, the old version had a manual. Unfortunatly, I haven't had time to write a new one. Click my name <---, the contact me on any one of my screen names, and I'll show ya the ropes :)
  • 0

#18 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 12 September 2005 - 09:52 PM

Alright, wow a nice and smart person all in one!

I think I have been doing pretty good so far, and so far this actaully works!
  • 0

#19 GmDude66

GmDude66

    GMC Member

  • New Member
  • 348 posts
  • Version:Unknown

Posted 12 September 2005 - 09:54 PM

Upgraded to GMsock 3.1.0.521, he didn't have time to post that he upgraded it so I will do this for him.


Anyways the same link is now download to 3.1.0.521....


Re-download if you want NEWEST version..

~Derek~

Edited by GmDude66, 12 September 2005 - 10:07 PM.

  • 0

#20 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 12 September 2005 - 09:56 PM

EDIT: This bug is in version 3.1 (The newest one)


I also found a bug. Small bug but can cause huge problems.

It is in the sock_message_recive(...) script.


Your script looks like this:

/*identical to mplay_message_receive
first arg:  socket identifier returned by sock_connect or sock_accept
returns:    1 if message received, 0 if not.
*/
if (argument0 == -1)
   return "";
var char;
if (string_pos(chr(10),sock_buf(sock)) == 0)
   return 0;
char = ord(sock_receive(argument0));
if (char < 0)
   return 0;
global._GMSOCK_MESSAGE_ID = char;
global._GMSOCK_MESSAGE_VALUE = sock_token_receive(argument0,chr(10));
return 1;

but this line:

if (string_pos(chr(10),sock_buf(sock)) == 0)

should be:

if (string_pos(chr(10),sock_buf(argument0)) == 0)

were sock was changed to argument0. Than it works after that.

Edited by Rune Hunter, 12 September 2005 - 09:57 PM.

  • 0

#21 MP2:E

MP2:E

    GMC Member

  • New Member
  • 152 posts

Posted 12 September 2005 - 11:05 PM

w00t!! GMSock Threaded Rulez!!!! :)
  • 0

#22 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 13 September 2005 - 11:49 AM

EDIT: This bug is in version 3.1 (The newest one)


I also found a bug. Small bug but can cause huge problems.

It is in the sock_message_recive(...) script.


Your script looks like this:

/*identical to mplay_message_receive
first arg:  socket identifier returned by sock_connect or sock_accept
returns:    1 if message received, 0 if not.
*/
if (argument0 == -1)
   return "";
var char;
if (string_pos(chr(10),sock_buf(sock)) == 0)
   return 0;
char = ord(sock_receive(argument0));
if (char < 0)
   return 0;
global._GMSOCK_MESSAGE_ID = char;
global._GMSOCK_MESSAGE_VALUE = sock_token_receive(argument0,chr(10));
return 1;

but this line:

if (string_pos(chr(10),sock_buf(sock)) == 0)

should be:

if (string_pos(chr(10),sock_buf(argument0)) == 0)

were sock was changed to argument0. Than it works after that.

<{POST_SNAPBACK}>

:)
I never cease to amaze even myself sometimes. And I would probably never catch that, as I always call my sockets sock :D

Anyway, thanks much for that, I've uploaded a bugfix version. If you don't feel like downloading it, just perform the tweak in Rune Hunter's post.

Matthewbot
  • 0

#23 Bathy

Bathy

    GMC Member

  • New Member
  • 504 posts

Posted 13 September 2005 - 10:41 PM

I have a suggestion for you Matt. This dll is great, but it has always been missing one thing.. compression -string packing-, add that and a basic xor encryption and this dll would be the best of the bunch.


Bathy

Edited by Bathy, 13 September 2005 - 10:42 PM.

  • 0

#24 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 14 September 2005 - 01:10 AM

Also you should really update your program that adds the functions in the game maker function list.

I find out that sock_connected is no longer used, but I got an error. I'm sure it is fixable by looking through the script but for simplicity and functions we might miss an update on that would be nice.
  • 0

#25 GmDude66

GmDude66

    GMC Member

  • New Member
  • 348 posts
  • Version:Unknown

Posted 14 September 2005 - 08:27 PM

@RuneHunter: You can update it yourself if you know a little c++ =P. He has the source included.

I might even update the function added for Matt, BRB.
  • 0

#26 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 14 September 2005 - 08:49 PM

ahhh I supose... but a new problem emerged.

there is sock_flush_auto and sock_flush_char but there is NO sock_flush() anymore!

It isn't in the dll init function so has it been taken out or what happened?


EDIT: Aparently it was just never added to the init function, I seem to have added it my self sucesfully but should be added in the download.

Add this like to the sock_init() function script:

global._GMSOCK_OBUF_FLU = external_define(dir+"\GMsock.dll","GMflush",dll_cdecl,ty_real,1,ty_real);

NOTE: This is not 100% garanteed to work, it just apearnlty worked for me.

Edited by Rune Hunter, 14 September 2005 - 09:23 PM.

  • 0

#27 Smarttart62

Smarttart62

    designFUSION

  • New Member
  • 2619 posts

Posted 14 September 2005 - 09:04 PM

I am soo updating SFX online with this, and also i agree with what bathy says up there :D...

Good job!!!
-Steve
  • 0

#28 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 14 September 2005 - 11:15 PM

ahhh I supose... but a new problem emerged.

there is sock_flush_auto and sock_flush_char but there is NO sock_flush() anymore!

It isn't in the dll init function so has it been taken out or what happened?


EDIT: Aparently it was just never added to the init function, I seem to have added it my self sucesfully but should be added in the download.

Add this like to the sock_init() function script:

global._GMSOCK_OBUF_FLU = external_define(dir+"\GMsock.dll","GMflush",dll_cdecl,ty_real,1,ty_real);

NOTE: This is not 100% garanteed to work, it just apearnlty worked for me.

<{POST_SNAPBACK}>

:D Man, don't know how I missed that. Really should've gotten some beta testers, I suppose. Seeing as how thats the second bug you've uncovered, would you like to beta test? :snitch: For the next large release, that is.

@Bathy, sure, I'll add those. Doesn't sound too difficult. I'll have Rune Hunter's bugfix and encrption in the next release. As for string packing, I don't really know what you mean. We have message functions already, designed for sending a combination of numbers and strings based on a format. And compression would be kind of difficult with my current system, besides, its not really worth it for small amounts of data you're (usually) sending in games, due to the incredible overhead involved.
  • 0

#29 Bathy

Bathy

    GMC Member

  • New Member
  • 504 posts

Posted 14 September 2005 - 11:34 PM

What I mean is functions to pack and unpack numbers of various sizes to strings of bytes. It really has nothing to do with your format and message system.

Edited by Bathy, 14 September 2005 - 11:35 PM.

  • 0

#30 GmDude66

GmDude66

    GMC Member

  • New Member
  • 348 posts
  • Version:Unknown

Posted 15 September 2005 - 12:43 AM

I'll beta test for you.

~Derek~
  • 0

#31 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 15 September 2005 - 02:07 AM

I am basicly beta testing right now hehe. But I guess. This project is really advanced and can only get better.

I also have a few question.

When I send a message and I do a while look like this:

while (sock_message_recive(sock))
{
//code here
}

it seems to always pass through the code even if no message is there. Because I sent a simple message to test it out and it was somthing like a simple chat system. I sent the message, the other program did a loop just like a win32 program does it's message loop and it kept reading that one message over and over even though it was sent once.

If you can make sence out of that, it would be great if you could help me.
  • 0

#32 gamemaker intermediate

gamemaker intermediate

    GMC Member

  • New Member
  • 123 posts

Posted 15 September 2005 - 03:42 AM

:D your getting pretty good at this sock thing nice work
  • 0

#33 39ster

39ster

    GMC Member

  • GMC Member
  • 898 posts

Posted 15 September 2005 - 04:20 AM

@Bathy, sure, I'll add those. Doesn't sound too difficult. I'll have Rune Hunter's bugfix and encrption in the next release. As for string packing, I don't really know what you mean. We have message functions already, designed for sending a combination of numbers and strings based on a format. And compression would be kind of difficult with my current system, besides, its not really worth it for small amounts of data you're (usually) sending in games, due to the incredible overhead involved.

<{POST_SNAPBACK}>

I think he means data types like short's, integers, etc..Not actual compression like winzip or whatever.
  • 0

#34 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 15 September 2005 - 11:36 AM

Hey guys, thanks for all the support. Really sorry about all these glitches. I guess I should've posted another beta then the full release, since the first one didn't get much attention (probably becuase SOC just came out). Live and learn, I guess.

Rune Hunter, could u possibly PM me a link to an example of this phenomona? It always seems to work fine for me.

@39ster, yea I know. Technically writing things as a short or as an integer isn't compression, you know. He said he was going to add them to GMsock himself, so if they work good, I'll merge them into the next release.
  • 0

#35 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 15 September 2005 - 08:25 PM

I see you have msn, and I would much rather fix this problem on there seeming the file is small and msn messenger has a nice small file transfer program. If you don't mind that is.

But sence your off at the time of this post, I guess I will pm it for now.

Edited by Rune Hunter, 15 September 2005 - 08:25 PM.

  • 0

#36 Ptolemy

Ptolemy

    ACDC Fan

  • GMC Member
  • 216 posts

Posted 20 September 2005 - 09:07 PM

Nice DLL im making a chat program with it right now.
It's working really nicely too.
~Ptolemy
  • 0
GM User since '02

#37 yahn

yahn

    GMC Member

  • New Member
  • 331 posts

Posted 20 September 2005 - 09:26 PM

very impressive. it seems to work much faster then the last version. i noticed something wierd though, maybe its just my firewall or router or something, but for some reason sometimes when i connect tcp its sending like a default message or something. it doesn't appear to have anything in it, but its not like a regular message with nothing in it. (that didn't make much sense.) has anyone else noticed this? or is this just something wierd with my computer?
  • 0

#38 Rune Hunter

Rune Hunter

    GMC Member

  • New Member
  • 317 posts

Posted 21 September 2005 - 12:59 AM

Thats weird it doesn't seem to send any messages for me. I pmed him the problem and example, so I am waiting now.

(It does send some at the begining but putters out on me)
  • 0

#39 PromaneX

PromaneX

    Fixer of broken web things

  • New Member
  • 489 posts

Posted 21 September 2005 - 02:34 AM

I cant seem to connect to the website for this. is it down ? :(
  • 0

#40 J-Labs

J-Labs

    J-Labs

  • New Member
  • 339 posts

Posted 21 September 2005 - 03:50 AM

Yeah the dl is down I cant download fix it plz.
  • 0

#41 PromaneX

PromaneX

    Fixer of broken web things

  • New Member
  • 489 posts

Posted 21 September 2005 - 05:10 AM

j-labs your GEO link is dead also...
  • 0

#42 hsv88

hsv88

    GMC Member

  • New Member
  • 33 posts

Posted 21 September 2005 - 07:06 AM

This is an awsome dll great work as always matt.
One feature that i think would be handy though is a fuction to connect through a proxy. Ive been searching for a GMsock project that can use a proxy but i can't find any.
  • 0

#43 matthewbot

matthewbot

    The Sockmaster

  • New Member
  • 258 posts

Posted 21 September 2005 - 11:35 AM

Terribly sorry about the site being down, I'm currently in the process of switching sites. I've got a termporary spot for it though, so I've updated the main post.
  • 0

#44 Tobs

Tobs

    GMC Member

  • New Member
  • 599 posts

Posted 21 September 2005 - 12:50 PM

Nice work Matt, i thought you had ditched the socket stuff ages ago, when you didn't reply in your old topic...
Ill be off to do some more online programming now =D

H3x
  • 0

#45 GmDude66

GmDude66

    GMC Member

  • New Member
  • 348 posts
  • Version:Unknown

Posted 21 September 2005 - 08:59 PM

GMsock 3.1.0.521 (Right Click-> Save As)

Theres a mirror for whenever Matt's host is down.

~Derek~

Edited by GmDude66, 02 October 2005 - 03:42 PM.

  • 0

#46 PromaneX

PromaneX

    Fixer of broken web things

  • New Member
  • 489 posts

Posted 22 September 2005 - 01:26 AM

Another one to give you some choice lol

[DIRECT LINK] - GMsockth.zip(51KB)

I love it ::lmao::
  • 0

#47 LordDas

LordDas

    GMC Member

  • New Member
  • 60 posts

Posted 23 September 2005 - 02:31 PM

mmm old version of gmsock works better than this..
for somereason it takes 2 tries to connect or sometimes 3 to coonect to my vb6 server running winsock(tcp)
and... still when the gamemaker executable ends the winsock connection doesnt close.. like normal winsock controls do in vb6
im using 2.1.0.0 of the gmsock.dll wonderful thing :lol: thanks matt anyway!
but that problem still exist in that version as well though ;)

- LordDas
  • 0

#48 GmDude66

GmDude66

    GMC Member

  • New Member
  • 348 posts
  • Version:Unknown

Posted 23 September 2005 - 07:34 PM

@LordDas: Works fine for me on any version of GMsock in one try.

~Derek~
  • 0

#49 J-Labs

J-Labs

    J-Labs

  • New Member
  • 339 posts

Posted 28 September 2005 - 10:30 PM

j-labs your GEO link is dead also...

<{POST_SNAPBACK}>


Yeah I stopped production simply because of the fact that the game has too basic programing for my standards now...I guess I'll update my logos and stuff.

Back on topic: Okay well it would help if you had more help (examples, tutorials) and stuff because gmsock is pretty difficult (at least for me) . So its either this or ultimate mplay.
  • 0

#50 Rebound->

Rebound->

    GMC Member

  • New Member
  • 152 posts

Posted 29 September 2005 - 02:31 AM

I maybe wrong, as i haven't downloaded GMSock 3 yet, but if its anything like GMSock2, just read through that help file as a starter. Then aren't that many tutorials/examples because (well, imo anyway) people are too busy or uneducated in making a tutorial/example. But if you just play around with the old help file, and some of the tutorials/examples at the GMSock forums you should get the basics, and maybe even pick up some advanced concepts of coding with GMSock, i sure did.
Though this is only on the assumption that GMSock3 is similiar to GMSock 2.

Hope this helps

-Rebound
  • 0

Inforticle - The Free Informative Article Directory
Bullfee - The New and Innovative Online Store