Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


#ActualSky Warden

Posted 28 May 2013 - 12:08 AM

hplus0603, on 27 May 2013 - 23:25, said:
You can't directly make the login() function return the data. You have to instead defer a function that gets called with the result of the login. If I remember correctly, you use reactor.callLater() for this: http://twistedmatrix.com/documents/12.3.0/core/howto/defer.html


Which functions I need to defer? The caller of the login() function (the celcommand_login())? So I need to fetch the result of that function after it's ready? And if it needs more than x seconds it will return nothing?

Uhm... code please? If you fix my code I can learn it quickly. I know it sounds demanding and lazy, but I'm not. I'm very eager to learn, and the best way I can learn logic is by reading code. unsure.png

I really need to get this concept. I'm sure once I understand this problem I will be able to make an interesting progress.


I'm also trying to make another version (in case my logic is wrong in this version) with another logic flow. The difference is that I write the data to the socket via callbacks. The problem I get in this version is circular dependency. The DatagramProtocol class needs the Service class to call the login function in it, and the Service class needs the DatagramProtocol class to do the transport.write.

Oh my brain...
 

 

I also made the more ignorant version. Everything runs in one service. It's very very dirty, but kinda working. I still don't feel right about it though. I will only use it if the first version can't be helped.

 

hplus0603, on 27 May 2013 - 23:25, said:
For getting the source address, in UDP, there is only one client socket, and the source address is available on each incoming packet; you then have to do the mapping from address to client yourself, whereas TCP does that for you.

Oh, yes. I know that the datagram contains the address of the sender. I was wondering if we could get the address exactly when a connection is made, like in TCP. I forgot that UDP only has one socket. laugh.png

 

hplus0603, on 27 May 2013 - 23:25, said:
And, yes, the 4-hour "pymmo" example was indeed something I did one late night :-)


That thing is amazing, sir, and you said you did it while learning a new language. Your pymmo really needs more publication. blink.png

By the way, why do I have to connect to the Internet to use UDP? If I'm not connected to the Internet it will say "no such devices" or something similar.


#2Sky Warden

Posted 27 May 2013 - 11:54 PM

hplus0603, on 27 May 2013 - 23:25, said:
You can't directly make the login() function return the data. You have to instead defer a function that gets called with the result of the login. If I remember correctly, you use reactor.callLater() for this: http://twistedmatrix.com/documents/12.3.0/core/howto/defer.html


Which functions I need to defer? The caller of the login() function (the celcommand_login())? So I need to fetch the result of that function after it's ready? And if it needs more than x seconds it will return nothing?

Uhm... code please? If you fix my code I can learn it quickly. I know it sounds demanding and lazy, but I'm not. I'm very eager to learn, and the best way I can learn logic is by reading code. unsure.png

I really need to get this concept. I'm sure once I understand this problem I will be able to make an interesting progress.


I'm also trying to make another version (in case my logic is wrong in this version) with another logic flow. The difference is that I write the data to the socket via callbacks. The problem I get in this version is circular dependency. The DatagramProtocol class needs the Service class to call the login function in it, and the Service class needs the DatagramProtocol class to do the transport.write.

Oh my brain...

hplus0603, on 27 May 2013 - 23:25, said:
For getting the source address, in UDP, there is only one client socket, and the source address is available on each incoming packet; you then have to do the mapping from address to client yourself, whereas TCP does that for you.


Oh, yes. I know that the datagram contains the address of the sender. I was wondering if we could get the address exactly when a connection is made, like in TCP. I forgot that UDP only has one socket. laugh.png


hplus0603, on 27 May 2013 - 23:25, said:
And, yes, the 4-hour "pymmo" example was indeed something I did one late night :-)


That thing is amazing, sir, and you said you did it while learning a new language. Your pymmo really needs more publication. blink.png

By the way, why do I have to connect to the Internet to use UDP? If I'm not connected to the Internet it will say "no such devices" or something similar.

#1Sky Warden

Posted 27 May 2013 - 07:55 PM

You can't directly make the login() function return the data. You have to instead defer a function that gets called with the result of the login. If I remember correctly, you use reactor.callLater() for this: http://twistedmatrix.com/documents/12.3.0/core/howto/defer.html

 

Which functions I need to defer? The caller of the login() function (the celcommand_login())? So I need to fetch the result of that function after it's ready? And if it needs more than x seconds it will return nothing?

 

Uhm... code please? If you fix my code I can learn it quickly. I know it sounds demanding and lazy, but I'm not. I'm very eager to learn, and the best way I can learn logic is by reading code. unsure.png

 

I really need to get this concept. I'm sure once I understand this problem I will be able to make an interesting progress.

 

 

I'm also trying to make another version (in case my logic is wrong in this version) with another logic flow. The difference is that I write the data to the socket via callbacks. The problem I get in this version is circular dependency. The DatagramProtocol class needs the Service class to call the login function in it, and the Service class needs the DatagramProtocol class to do the transport.write.

 

Oh my brain...

 

For getting the source address, in UDP, there is only one client socket, and the source address is available on each incoming packet; you then have to do the mapping from address to client yourself, whereas TCP does that for you.

 

Oh, yes. I know that the datagram contains the address of the sender. I was wondering if we could get the address exactly when a connection is made, like in TCP. I forgot that UDP only has one socket. :lol:

 

 

And, yes, the 4-hour "pymmo" example was indeed something I did one late night :-)

 

That thing is amazing, sir, and you said you did it while learning a new language. Your pymmo really needs more publication. blink.png


PARTNERS