Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Client/Server Recognition using mplay functions  (Read 2293 times)

0 Members and 1 Guest are viewing this topic.
Client/Server Recognition using mplay functions
« on: August 31, 2010, 08:17:02 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 41
I'm working on a Zelda MMO and I'm having trouble connecting from my client.exe to my server.exe. The latter sets up the session fine (as I get a confirmation of it happening) while the former will never connect no matter what address I give it or don't.

Here's the code I'm using:
Code: Text
  1. if (mplay_init_tcpip("")) {
  2.     if (mplay_session_create("",0,"")) {
  3.         show_message("Server started!"); // I get this everytime :D
  4.     }
  5.     else {
  6.         show_message("Unable to launch server!");
  7.     }
  8. }
  9.  

Code: Text
  1. if (mplay_init_tcpip("127.0.0.1")) {
  2.     if (mplay_session_find() > 0) {
  3.         if (mplay_session_join(0,'')) {
  4.             show_message("Connected to server!");
  5.         }
  6.         else {
  7.             show_message("Failed to join a session.");
  8.         }
  9.     }
  10.     else {
  11.         show_message("No session available to join."); // The error I keep getting :|
  12.     }
  13. }
  14. else {
  15.     show_message("Failed to connect!")
  16. }
  17.  

Any suggestions?
Logged
Re: Client/Server Recognition using mplay functi...
« Reply #1 on: August 31, 2010, 12:14:30 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1767
Well first off, I wouldn't ever use GM's built in mplay functions. Look into using 39dll or at least SOCdll.

As for the error, the only thing I could say is that the server isn't actively listening. I don't know the mplay functions that well, and I'm at school so I can't check, so maybe it is. It seems to maybe need an mplay_listen(?) type function of sorts, so it can connect.
Logged
  • https://colbydude.com
Re: Client/Server Recognition using mplay functi...
« Reply #2 on: September 01, 2010, 02:40:14 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 41
This project is extremely small scale, I think I can get away with the built in functions. As for the problem itself I think it was a gamemaker related error with not being able to connect between programs. I put the same code into a single game and it worked fine :/
Logged
Re: Client/Server Recognition using mplay functi...
« Reply #3 on: September 01, 2010, 02:52:29 pm »
  • d(-_-)b
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 36
Here is the error, 0 is the first session:
Code: [Select]
if (mplay_session_find() > 0)
Logged
Re: Client/Server Recognition using mplay functi...
« Reply #4 on: September 03, 2010, 12:30:15 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 41
Here is the error, 0 is the first session:
Code: [Select]
if (mplay_session_find() > 0)
Pretty sure that's not the problem.
Logged
Re: Client/Server Recognition using mplay functi...
« Reply #5 on: September 03, 2010, 02:43:40 pm »
  • d(-_-)b
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 36
Here is the error, 0 is the first session:
Code: [Select]
if (mplay_session_find() > 0)
Pretty sure that's not the problem.

Did you test it using -1 instead of 0?
Logged
Re: Client/Server Recognition using mplay functi...
« Reply #6 on: September 03, 2010, 05:44:54 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
From the GameMaker help files
Quote
mplay_session_find() searches for all sessions that still accept players and returns the number of sessions found.

Thus if the function returns 0 there are no open sessions. The line is correct.

From what I have heard is that GM itself is not really good in the networking department. Personally I have never worked with it in GM, but in other languages I remember that it was also necessary for the server to open the port it will be listening to. And the client connects on that port as well. In addition you need to have the server actively listening for new connections.

But then again I don't know what GM already does for you. It seems to me that it does not connect either because the server isn't listening or that they aren't working on the same port. You leave a lot of arbitrary values open for GM to fill in. It might be that during compile time these values are determined by GM and that it isn't always the same. But this is me guessing. Try giving values yourself. Thus no empty strings and
Logged
Re: Client/Server Recognition using mplay functi...
« Reply #7 on: September 03, 2010, 10:31:09 pm »
  • d(-_-)b
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 36
Sorry, now that Niek post what the function does, I notice that I have read the wrong line in gm help file, well... !@#$% happens :[
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.146 seconds with 51 queries.

anything