Jump to content


Photo

Faucet Networking


  • Please log in to reply
397 replies to this topic

#381 AngerAlone

AngerAlone

    GMC Member

  • New Member
  • 19 posts
  • Version:GM8

Posted 23 May 2013 - 06:43 PM

I'm having some issues with this. I've taken the code in the pong example and modified it to fit the purposes of my game. The pong example, for those who don't know, was a simple tcp connection that was easy to setup/understand. I've appended the relevant network portions to my game, and I've got the host/client connection functioning fine. However, many of the objects in the gameroom aren't being created when the room switches from the startroom, so I'm left with a connected room that can't be played because the most importants objects just don't spawn. Anyone have any ideas as to why this might be happening?

 

I should also mention that I've tried running the game both locally and over the internet, and that the game functions perfectly well if I don't have the networking enabled.


Edited by AngerAlone, 23 May 2013 - 06:58 PM.

  • 0

#382 Medo42

Medo42

    GMC Member

  • GMC Member
  • 226 posts

Posted 23 May 2013 - 07:26 PM

Faucet Networking is not in the business of creating Game Maker objects, that is up to your code. However, you don't provide enough information about your code to tell you why it is not creating the objects you expect to be created, so we can't really help you.

 

However, you should note that the Pong example code does not have any provision for synchronizing the creation and destruction of objects either, since this just never happens in the Pong game - there are always two paddles and one ball. You can extend the protocol to handle this by adding new types of message for creating / destroying objects, but how best to go about this depends on your game.


  • 0

#383 AngerAlone

AngerAlone

    GMC Member

  • New Member
  • 19 posts
  • Version:GM8

Posted 24 May 2013 - 07:48 PM

Disregard.


Edited by AngerAlone, 24 May 2013 - 08:21 PM.

  • 0

#384 battlefront

battlefront

    GMC Member

  • GMC Member
  • 60 posts
  • Version:Unknown

Posted 28 May 2013 - 06:54 PM

Hello.  I am using faucet networking, after switching over from 39dll lol.  Does it have any advantages over the gm studio networking?


  • 0

#385 Medo42

Medo42

    GMC Member

  • GMC Member
  • 226 posts

Posted 28 May 2013 - 08:27 PM

I finally took the time to read up on the Studio Networking. Having an event for the networking is interesting, but overall I don't like their new API much. The documentation does not make sense in places (IPs adresses deal with ports? You look up the IP of a URL?), and there is no IPv6 support. I'm not even sure if you can use this for "plain" TCP communication - there is a send_raw function which is apparently for sending data without the "GM packet" header, but I'm not sure how that is supposed to work together with the receiving event, which seems to rely on that header.

 

There are other details, e,g, that the lookup function assumes that every hostname resolves to exactly one IP - try google.com, that gives me 11 IPv4 adresses right now (and one IPv6).

 

Overall, I don't see much benefit in it over Faucet Net, except that it's the official standard solution now.


  • 2

#386 darknessspliter

darknessspliter

    GMC Member

  • GMC Member
  • 43 posts
  • Version:GM8

Posted 08 June 2013 - 06:09 PM

Hey MedO!First I want to thank you about faucet networking,because it's very easy to use.I am advancing with my game a lot,made some graphics and animation stuff already,player attacks etc.Gonna add the different weapons and armor stuff very soon. :P However I think I have problem:

 

I am using the epic lagless movement system where client sends coordinates and h/vspeed,only when he presses or releases arrow key.The server puts the received coordinates in the player objects and moves them with the received speed.

 

However I think that this method allows the client to cheat the game too much,because he can send any coordinates to server.So do you have an idea how to make anti-cheat code,that checks if player speedhack and kicks him?Or should I rewrite my whole movement system?


Edited by darknessspliter, 08 June 2013 - 06:12 PM.

  • 0

#387 Medo42

Medo42

    GMC Member

  • GMC Member
  • 226 posts

Posted 09 June 2013 - 04:20 PM

Yes, that makes cheating easy. One solution would be to let the clients only send the actual commands to the server (key pressed or released, special action x ) and let the server run the game logic to figure out how everyone is moving. This is what GG2 does.


  • 0

#388 darknessspliter

darknessspliter

    GMC Member

  • GMC Member
  • 43 posts
  • Version:GM8

Posted 09 June 2013 - 08:43 PM

Yes, that makes cheating easy. One solution would be to let the clients only send the actual commands to the server (key pressed or released, special action x ) and let the server run the game logic to figure out how everyone is moving. This is what GG2 does.

Thats an idea,gonna try it tomorow ;)

EDIT:It worked perfectly!


Edited by darknessspliter, 11 June 2013 - 09:39 AM.

  • 0

#389 T-bond

T-bond

    GMC Member

  • GMC Member
  • 4 posts
  • Version:GM8

Posted 12 June 2013 - 06:24 PM

Hello!

 

I need your help again.

 

I want to make a download script with parameters.
Download with GET is working perfectly, but I want to send my arguments in POST method.
How can I do that?

I think I have to modify these lines:

tb_download=tcp_connect("www."+string(argument0),80);
write_string(tb_download, "GET http://"+string(argument0)+"/"+string(argument1)+chr(13)+chr(10));
socket_send(tb_download);

If I replace GET to POST the file output will be this in every case:
 

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

What can I do?


  • 0

#390 Medo42

Medo42

    GMC Member

  • GMC Member
  • 226 posts

Posted 12 June 2013 - 07:08 PM

Hi. Sending POST requests and parameters is a bit different from GET requests. The parameters go into the actual request body with POST, and you need to set headers to tell the server what your request body looks like.

Faucet Net isn't really the ideal match for this since you have to do everything on foot. Consider using a second library that knows about HTTP, like the well-known HTTP DLL 2.


  • 0

#391 MonkeyArm

MonkeyArm

    GMC Member

  • New Member
  • 2 posts
  • Version:GM7

Posted 12 June 2013 - 07:44 PM

Hello Medo42, congratulations for your extension, I have read only positive comments. I'm a 39dll user, and a long time ago I created a mmorpg with 3d graphics. Clearly, when the number of players increases, you have to start to think about a multiserver architecture (obviously I don't mean p2p). So I was wondering about the scalability of your extension. Does it use non-blocking I/O functions like tornado for python? It would really put you in the Olympus of the networking programmers if you could add some multiserver support, like chosing a server from a list, or handling some communication between servers, etc, even if I know it's really hard to implement...


  • 0

#392 T-bond

T-bond

    GMC Member

  • GMC Member
  • 4 posts
  • Version:GM8

Posted 12 June 2013 - 09:22 PM

Hi. Sending POST requests and parameters is a bit different from GET requests. The parameters go into the actual request body with POST, and you need to set headers to tell the server what your request body looks like.
Faucet Net isn't really the ideal match for this since you have to do everything on foot. Consider using a second library that knows about HTTP, like the well-known HTTP DLL 2.


Thank you.
I will use a dll then.
  • 0

#393 darknessspliter

darknessspliter

    GMC Member

  • GMC Member
  • 43 posts
  • Version:GM8

Posted 13 June 2013 - 01:11 PM

https://mega.co.nz/#...O4bEaWxtbrpCFJc

Here are the two kinds of movement,made by me,I upload it to help the others. ;)


  • 0

#394 Medo42

Medo42

    GMC Member

  • GMC Member
  • 226 posts

Posted 13 June 2013 - 09:59 PM

Hello Medo42, congratulations for your extension, I have read only positive comments. I'm a 39dll user, and a long time ago I created a mmorpg with 3d graphics. Clearly, when the number of players increases, you have to start to think about a multiserver architecture (obviously I don't mean p2p). So I was wondering about the scalability of your extension. Does it use non-blocking I/O functions like tornado for python? It would really put you in the Olympus of the networking programmers if you could add some multiserver support, like chosing a server from a list, or handling some communication between servers, etc, even if I know it's really hard to implement...

Hi MonkeyArm, and thanks. First, the extension is entirely nonblocking. Everything that could block (e.g. hostname lookups, or sending large ammounts of data) is delegated to a background thread.

 

You can implement any kind of multiserver architecture using Faucet Net, but those things involve questions like "how do I keep my world state consistent between servers?" and "How do I balance players between servers". Faucet Net doesn't concern itself with world state, players or any other game-related, high-level concepts like this, because it is intended to be a low-level socket library, not a one-stop networking engine. You could build one on top of Faucet Net, but if you start here, expect to do the footwork yourself.


  • 0

#395 MonkeyArm

MonkeyArm

    GMC Member

  • New Member
  • 2 posts
  • Version:GM7

Posted 14 June 2013 - 09:58 AM

I see, very pertinent and exhaustive answer. Well, I'll start to use your extension then, since its non-blocking properties are very promising in the context of large networks :) Have a nice day and thanks for your answer!


Edited by MonkeyArm, 14 June 2013 - 10:01 AM.

  • 0

#396 j0nteh

j0nteh

    GMC Member

  • GMC Member
  • 81 posts
  • Version:Unknown

Posted 17 June 2013 - 02:02 PM

I'm having some troubles sending two strings after one another.

 

Client:

    write_byte(serverSocket,6);
    write_ushort(serverSocket,2+string_length(obj_namebox.name));
    write_ushort(serverSocket,string_length(obj_namebox.name));
    write_string(serverSocket,obj_namebox.name)
    
    write_ushort(serverSocket,2+string_length(obj_passbox.password));
    write_ushort(serverSocket,string_length(obj_passbox.password));
    write_string(serverSocket,obj_passbox.password)
    socket_send(serverSocket);

Server:

while (tcp_receive(socket,2)) // 
{
    //get name
    expectedbytes=read_ushort(socket);
    tcp_receive(socket,expectedbytes);
    stringlength=read_ushort(socket);
    _name = read_string(socket,stringlength);
    //get password
    expectedbytes=read_ushort(socket);
    tcp_receive(socket,expectedbytes);
    stringlength=read_ushort(socket);
    _pass = read_string(socket,stringlength);
}

Using this code, I succesfully manage to extract the name, but not the password.

I've tried so many things, I just can't figure out how to do it.


Edited by j0nteh, 17 June 2013 - 02:03 PM.

  • 0

#397 Medo42

Medo42

    GMC Member

  • GMC Member
  • 226 posts

Posted 17 June 2013 - 10:29 PM

The writing part is OK, though a bit redundand - why do you first send the length+2 and then the length again for each string? There *might* be a good reason for this, but your receiving code doesn't look like that applies.

 

The receiving code has several issues though. After looking at it for a bit I think I understand where you are coming from, but you seem to have some misconceptions about how TCP behaves, and what the functions do.

First off, a TCP connection is a stream of bytes. If you want to use it to send separate *messages*, there is no way to tell where one message starts and ends unless you provide a way yourself, e.g. saying how long each message is.

 

I'm guessing that your while loop is intended to receive several blocks of username+password, so it would loop until they have all been received. However, that won't work reliably, because as I said TCP itself doesn't have a way to tell where the message ends. If you send two usernames and passwords, you won't know when to stop reading them unless you e.g. send the count beforehand. The code you wrote might only get one of the pairs, or it might get all two and then also start consuming the next thing that was sent, because it has already arrived.

 

Very related, you have to assume that any call to tcp_receive can fail because the data you wait for has not arrived yet. Yes, even if you sent that data in one call to socket_send. You can send "Hello World" and then "How are you" and receive it as "Hello Wo" "rldHow a" "re you", or as "Hello WorldHow are you" or really split up in any way. So if you just received "Hello" you can't assume that "World" has already arrived as well. You have two calls to tcp_receive within your loop where you don't actually check if the data was received or not. That is always an error, as I just explained.

 

All that said, I think your immediate problem is that you don't try to receive the second length header, e.g. you would need another tcp_receive(socket, 2) below "// get password". However, I hope I made clear that the code is still badly broken if you fix this problem, even though it will probably work most of the time on your local network.


  • 0

#398 Boudoudou

Boudoudou

    GMC Member

  • GMC Member
  • 102 posts

Posted Yesterday, 01:59 AM

Hello i'm using this extension for the new game I used 39dll for 3 years and i'm fastly used to Faucet but I've a got a glitch that block me from sending string (chat message)

 

here is my code and the error very bizarre that happens.

 
    write_ubyte(serverSocket,5);
    write_ushort(serverSocket,Message); //Message is a constant
    write_ushort(serverSocket,global.cid);
    write_ubyte(serversocket,string_length(obj_local_player.chat))
    write_string(serverSocket,obj_local_player.chat)
        socket_send(serverSocket)
 
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of  Step Event1
for object net_manager:
 
Push :: Execution Error - Variable Get -1.serversocket(100022, -1)
 at gml_Script_client_begin_step (line -1) - <unknown source line>
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_client_begin_step (line 0)
called from - gml_Object_net_manager_Step_1 (line -1) - <unknown source line>
 

I never had that kind of error before and I tried everything but can't get it off

 

EDIT: Oh god shame on me 

 

one line was "serversocket" instead of "serverSocket" I spent 1 hour on this lol

 

 

anyway thank you for Faucet :-)


Edited by Boudoudou, Yesterday, 02:03 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users