Sonntag, 1. Juli 2012 23:34
I'm trying to figure out the correct way to spawn remote actors directly (without using a REST interface) and so far I'm able to spawn the actor and send messages to it, but I'm not sure I'm doing it the right way.
Here is how I've done it:
actors::PIDpid = actors::actor::spawn("tcp://localhost:1080/hello");
The problem with this approach is:
1. I'm initializing a Listener, which seems rather strange to me given that I don't want to host any actors on this process, just consume them. But if I don't initialize the tcp_listener, then I receive an getaddrinfo 10093 error:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC>net helpmsg 10093
Either the application has not called WSAStartup, or WSAStartup failed.
2. After I'm done sending my messages to my remote actor, how do I correctly end the connection? If I use tcp_listener::shutdown() get an error on my host process: Error: closesocket: 10038, which is what I'm trying to avoid, if possible.
I'm sorry if I'm overseeing something, but it isn't obvious to me the correct way to spawn a remote actor.
Montag, 2. Juli 2012 23:02Besitzer
This is a limitation in the (prototypical) implementation right now -- for your PID to be serializable, it has to be addressable, which means that there needs to be a listener ready to receive messages to the actor that sent the message. Eventually, we will clean this up so that you only need to have a listener if you are going to host actors.
For now, please consider it an inconvenience rather than a feature :-). If you're using actors for distribution, just initialize the listener early in your process (on_initialize() if your using our hosting libraries) and shutdown late (on_shutdown()).
- Als Antwort markiert ivanmantova Dienstag, 3. Juli 2012 21:21
Dienstag, 3. Juli 2012 21:22
Thank you for your answer, Niklas!
No problem. I just wanted to be sure I wasn't missing or misinterpreting something.