Jump to content


Photo

Faucet Networking


  • Please log in to reply
379 replies to this topic

#61 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 27 July 2011 - 08:10 PM

Fantastic work Medo. I was rather surprised that there wasn't a new example using UDP. It's easy enough for myself, but I can imagine new people to Faucet or online programming in general may struggle without something to look at. Can people expect an example in the future? If I get some more time I could possibly make one I suppose :)

It would be great if you can provide an example.
  • 0

#62 scorpeti

scorpeti

    GMC Member

  • New Member
  • 15 posts

Posted 03 August 2011 - 06:26 PM

Hi!
I tried the udp connection and it's a really cool stuff. Fast and easy to use.
My only problem is: I created a server on my computer and a friend tried to connect with udp from an other network. He has got a router and his computer is behind this router. The server tried to send data in udp with udp_send(buffer,ip,port), where the ip is the router's ip address. (80.76. ...) His computer's ip is 192.168.0.2 behind the router and there is an other computer in the network with this ip: 192.168.0.1. Of course, my data never arrived to my friend's computer and the game crashed, because the router didn't know where to transmit the data. My question is: how can I target his IP address behind a router? It would be great if many players could connect behind the same router and the server should send them different data with udp connection. So what should I do?
By the way, great job, I'm looking for updates. :)
  • 0

#63 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 03 August 2011 - 06:49 PM

Hi!
I tried the udp connection and it's a really cool stuff. Fast and easy to use.
My only problem is: I created a server on my computer and a friend tried to connect with udp from an other network. He has got a router and his computer is behind this router. The server tried to send data in udp with udp_send(buffer,ip,port), where the ip is the router's ip address. (80.76. ...) His computer's ip is 192.168.0.2 behind the router and there is an other computer in the network with this ip: 192.168.0.1. Of course, my data never arrived to my friend's computer and the game crashed, because the router didn't know where to transmit the data. My question is: how can I target his IP address behind a router? It would be great if many players could connect behind the same router and the server should send them different data with udp connection. So what should I do?
By the way, great job, I'm looking for updates. :)

You can't do this directly. Instead, you have two options. First, you can set up the router to forward certain ports to specific machines on your network. How you go about that depends on the router. The second option is to use NAT punchthrough (see e.g. http://www.mindcontr.../nat-punch.html), but that is a bit tricky and requires an "introducer" server that isn't behind a NAT router itself.
  • 0

#64 Bubatu

Bubatu

    GMC Member

  • New Member
  • 22 posts

Posted 07 August 2011 - 12:03 PM

Oh hey, I'm a newbie at this. I wanted to make an online game but when I found 39dll and faucet... I think I'm gonnaa give up.
These examples you gave me are still too complicated. xD
  • 0

#65 scorpeti

scorpeti

    GMC Member

  • New Member
  • 15 posts

Posted 18 August 2011 - 10:35 PM


Hi!
I tried the udp connection and it's a really cool stuff. Fast and easy to use.
My only problem is: I created a server on my computer and a friend tried to connect with udp from an other network. He has got a router and his computer is behind this router. The server tried to send data in udp with udp_send(buffer,ip,port), where the ip is the router's ip address. (80.76. ...) His computer's ip is 192.168.0.2 behind the router and there is an other computer in the network with this ip: 192.168.0.1. Of course, my data never arrived to my friend's computer and the game crashed, because the router didn't know where to transmit the data. My question is: how can I target his IP address behind a router? It would be great if many players could connect behind the same router and the server should send them different data with udp connection. So what should I do?
By the way, great job, I'm looking for updates. :)

You can't do this directly. Instead, you have two options. First, you can set up the router to forward certain ports to specific machines on your network. How you go about that depends on the router. The second option is to use NAT punchthrough (see e.g. http://www.mindcontr.../nat-punch.html), but that is a bit tricky and requires an "introducer" server that isn't behind a NAT router itself.

Well, I haven't got an introducer server, so the other option left. But I'm afraid I don't really understand you.

I set up my (the server's) router to forward every ports on TCP and UDP. (14804 was for TCP and 14805 was for UDP.) And it just didn't work. I changed the game's codes, so now every client watches an own different port to recieve udp messages. So now the used ports are from 14805-14899 for UDP connection, but it doesn't work either. I used portforwarding and DMZ, too. (DMZ=forwards every port for one IP.) If a client is behind a router, the server just doesn't see it. The client didn't use portforwarding, but I don't see the point to use and it would be sad if this is the only option. Is it okay, if I use this command like this: udp_send(udp_buffer,'80.76.xxx.xx',14805) ? I just don't get it, please help!
  • 0

#66 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 18 August 2011 - 10:51 PM

I set up my (the server's) router to forward every ports on TCP and UDP. (14804 was for TCP and 14805 was for UDP.) And it just didn't work. I changed the game's codes, so now every client watches an own different port to recieve udp messages. So now the used ports are from 14805-14899 for UDP connection, but it doesn't work either. I used portforwarding and DMZ, too. (DMZ=forwards every port for one IP.) If a client is behind a router, the server just doesn't see it. The client didn't use portforwarding, but I don't see the point to use and it would be sad if this is the only option. Is it okay, if I use this command like this: udp_send(udp_buffer,'80.76.xxx.xx',14805) ? I just don't get it, please help!

Your problem sounds more like a general networking question that isn't directly related to this extension, except for the last part - that udp_send call looks ok to me, assuming you don't actually have xxx.xx in the code.

I suggest using wireshark to find out which packets arrive where. Apart from that, networking questions that are not directly related to the extension should go to a Q&A site like stackoverflow.com.
  • 0

#67 scorpeti

scorpeti

    GMC Member

  • New Member
  • 15 posts

Posted 19 August 2011 - 06:42 AM


I set up my (the server's) router to forward every ports on TCP and UDP. (14804 was for TCP and 14805 was for UDP.) And it just didn't work. I changed the game's codes, so now every client watches an own different port to recieve udp messages. So now the used ports are from 14805-14899 for UDP connection, but it doesn't work either. I used portforwarding and DMZ, too. (DMZ=forwards every port for one IP.) If a client is behind a router, the server just doesn't see it. The client didn't use portforwarding, but I don't see the point to use and it would be sad if this is the only option. Is it okay, if I use this command like this: udp_send(udp_buffer,'80.76.xxx.xx',14805) ? I just don't get it, please help!

Your problem sounds more like a general networking question that isn't directly related to this extension, except for the last part - that udp_send call looks ok to me, assuming you don't actually have xxx.xx in the code.

I suggest using wireshark to find out which packets arrive where. Apart from that, networking questions that are not directly related to the extension should go to a Q&A site like stackoverflow.com.

Okay, I'll check and try to figure this out. Thanks.
  • 0

#68 qw5628

qw5628

    GMC Member

  • GMC Member
  • 7 posts

Posted 21 August 2011 - 10:21 AM

How can I send data to multiple client at once? In 39dll, I write data on 'one buffer' and send it via all sockets. But in Faucet networking, cuz all socket have its own buffer, I have to write data on 'one buffer' and then write_buffer for all socket's buffer again. Thus if there are 30 clients, I have to copy buffer 30 times. Is it only way to send same message to multiple clients simultaneously? I hope there is a better way to do it..
  • 0

#69 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 21 August 2011 - 01:21 PM

How can I send data to multiple client at once? In 39dll, I write data on 'one buffer' and send it via all sockets. But in Faucet networking, cuz all socket have its own buffer, I have to write data on 'one buffer' and then write_buffer for all socket's buffer again. Thus if there are 30 clients, I have to copy buffer 30 times. Is it only way to send same message to multiple clients simultaneously? I hope there is a better way to do it..

No, the way you described is the best option at the moment. I wouldn't be too concerned about performance though, since buffer copies are very fast, especially compared to filling a buffer in GML code. I just wrote a small test which simply writes 8MB of data to a buffer with repeated calls to write_double. To compare, I then copied this buffer 30 times to another buffer. The copying still took less than 10% of the time that was spent filling the buffer with write_double.

In other words, if the buffer content you are trying to send to everyone was created in GML, it is unlikely you will notice the performance difference created by the extra copying. And if you factor in that you'd have to write extra GML code in 39dll to ensure all your data is actually sent, the 39dll way of using nonblocking send calls without an extra buffer might even be slower (depending on buffer sizes). In any case, I'd need some convincing numbers to show this is actually a performance problem before I change anything about this.
  • 0

#70 Primoz128

Primoz128

    GMC Member

  • GMC Member
  • 277 posts
  • Version:GM8.1

Posted 23 September 2011 - 06:44 PM

So except that this looks like a 39dll functions put into bigger functions whats an actual advantage of this to the + of being an extension on the plus side ? Cause i am making a large game 8000 lines of code already and i occasionally get super logical error and i am just searching for multiplayer that will be used, 39dll works fine for me, but i don't understand how to threat new instances...
  • 0

#71 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 30 September 2011 - 10:37 PM

So except that this looks like a 39dll functions put into bigger functions whats an actual advantage of this to the + of being an extension on the plus side ? Cause i am making a large game 8000 lines of code already and i occasionally get super logical error and i am just searching for multiplayer that will be used, 39dll works fine for me, but i don't understand how to threat new instances...

There is a 39dll extension around (and turning any GM dll into an extension is easy), so this is not an actual advantage. Faucet Networking isn't just 39dll functions put in some wrapper though, it's a completely different implementation. The first post of this thread gives some overview of its advantages over 39dll, but the upshot is that Faucet Networking makes it easier to write correct nonblocking networking code. In addition, Faucet Networking is actively maintained, so if you find a bug it will actually be fixed.

Unfortunately I don't understand the second part of your post.
  • 0

#72 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 05 October 2011 - 10:03 AM

Faucet Networking v1.2.1 has been released!
Download here.

Yes, I completely skipped releasing V1.2 because it was such a small change ;)
Here's what's new:

  • Feature: New function write_buffer_part to append only a section of one buffer to another buffer
  • Bugfix: TCP acceptors could stop working on non-critical problems (e.g. when the network connection was lost for a short time)
  • Bugfix: Calling write_buffer() with the same buffer in both arguments could cause an illegal memory access

Edited by Medo42, 09 October 2011 - 09:34 AM.

  • 0

#73 Ember

Ember

    I made a bubble

  • GMC Member
  • 33 posts
  • Version:GM8

Posted 06 October 2011 - 03:40 PM

Yay~
I look forward to using this.
  • 0

#74 AdilFaQah

AdilFaQah

    Whiz Kid

  • GMC Member
  • 2744 posts

Posted 09 October 2011 - 09:04 AM

Very impressive. Certainly going to give this a shot.
  • 0

#75 2DLuis

2DLuis

    Graphic Designer

  • GMC Member
  • 2493 posts
  • Version:GM8

Posted 20 October 2011 - 08:09 PM

Very helpful source. Once you really try to program something large in 39dll, you'll quickly encounter its primitive limitations, especially with strings and overflows, very common. Libraries like this one, Raknet and Net39 really come to our rescue. For if it weren't for these, we'd have to reinvent the wheel. Great addition to the community!
  • 0

#76 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 132 posts
  • Version:GM8

Posted 12 December 2011 - 11:24 AM

I have a new idea.
Dll call of the GM is a slow side.

write_ubyte(Socket, 1);
write_ubyte(Socket, 5);
write_ubyte(Socket, 7);
write_ubyte(Socket, 8);

SO. This call is inefficient.

write_ubyte(Socket, 1, 5, 7, 8);

If this approach. you will get the simplicity and speed.

Edited by wnsrn3436, 12 December 2011 - 11:38 AM.

  • 0

#77 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 12 December 2011 - 06:59 PM

I have a new idea.
Dll call of the GM is a slow side.

write_ubyte(Socket, 1);
write_ubyte(Socket, 5);
write_ubyte(Socket, 7);
write_ubyte(Socket, 8);

SO. This call is inefficient.

write_ubyte(Socket, 1, 5, 7, 8);

If this approach. you will get the simplicity and speed.

This looks like a good idea which would simplify code in some situations, but as far as I know dll extension functions must have a fixed number of operands. That means we would either need to use different function names (e.g. write_ubyte_4(socket, 1, 5, 7, 8)) or fall back on variadic GML extension functions. This would cause additional overhead though and probably cancel any speed benefit you would get from this change.

Alternatively, we can keep the current functions but add a new set with plural names, e.g. "write_ubytes" which would be variadic. This would ensure there is no performance penalty for the current usage, but still allow the more concise version where appropriate. However, I don't really like the redundancy this creates from an API viewpoint.

Before I start making decisions based on performance, I should better go benchmark the different options to get a clearer image of the situation and whether it actually matters much.
  • 0

#78 wilbert

wilbert

    GMC Member

  • GMC Member
  • 6 posts
  • Version:GM8

Posted 15 December 2011 - 09:29 PM

multilayer is completely driving me crazy, 39dll causes all kinds of strange problems and this one too =[
i just tried to make a small test game with it and it appears that the buffer_write doesn't work or causes an error.

the pong example works fine but my little test chat program doesn't
http://www.mediafire...zzfp54b9p067r7x

I even used to get some run-time error about c++ but that's fixed now

Edited by wilbert, 15 December 2011 - 09:29 PM.

  • 0

#79 Medo42

Medo42

    GMC Member

  • GMC Member
  • 219 posts

Posted 15 December 2011 - 09:36 PM

multilayer is completely driving me crazy, 39dll causes all kinds of strange problems and this one too =[
i just tried to make a small test game with it and it appears that the buffer_write doesn't work or causes an error.

the pong example works fine but my little test chat program doesn't
http://www.mediafire.com/?zzfp54b9p067r7x

I even used to get some run-time error about c++ but that's fixed now

I will look at your source. You should not get c++ runtime errors though, I would be very interested to see the game source that led to this error.
  • 0

#80 wilbert

wilbert

    GMC Member

  • GMC Member
  • 6 posts
  • Version:GM8

Posted 15 December 2011 - 09:57 PM

oke thanks =]

i don't get the errors in this version of the of it anymore btw.
i might be able to recover an old .exe of it from skype but i don't have any gm files of it
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users