Reply To: Q& A from the chat

Home Forums Basic Erlang Q& A from the chat Reply To: Q& A from the chat

#33417

admin
Keymaster

Q:
Jan Kowalski (bulwersator): How can I check whatever something fulfils two conditions? Something like fun(X) -> X rem 13 =:= 0, X rem 3 =:= 0 end – but with AND operator, not OR. Sorry for stupid question.

A:
Maruthavanan Subbarayan (maruthavanan): for AND you have “andalso” keyword and for OR you have orelse keywords example https://github.com/jice/ehttph/blob/ce6a32998e3a27415f571a604a71f50e33235e33/include/ehttph_chars.hrl#L12


Q:
Denis Kononenko (chaos): How to use -extends directive?

A:
2013/12/11 [16:09:23] Tomasz Kowal: It is better not to use it at all: http://erlang.org/pipermail/erlang-questions/2012-October/070280.html

Q:
rastin rastini (rastinrastini): what must do if dont use extend?

A:
Tee Teoh (tteoh): use a process. every problem in Erlang can be solved by another process :D


Q:
Lili Bumbum (_flipout): Hey Guys, I have got a curious problem, I am able to ping from an erlang node a java node but not the otherway round
may someone please enlight me

A:
Mattias Jansson (mattias): is it on the same machine?
Lili Bumbum (_flipout): yes
rpc fails aswell
it seems that I am only able to contact from erlang but not from java
if I open another shell and try to contact the master node it works
erlang erlang works, erlang java works, but java erlang not

Mattias Jansson (mattias): what’s the code for creating the OtpNode instance?

Lili Bumbum (_flipout): mom
_node = new OtpNode(_node_name, “cookie”);_mbox = _node.createMbox(“do”);
just creating a node and a mailbox
I can receive messages
I didn’t try to response yet, because the initial contact has to be made by the java node

Mattias Jansson (mattias): and _node.ping(_node_name, “cookie”); returns false?

Lili Bumbum (_flipout): I am pining without cookie

Mattias Jansson (mattias): oh. right. ofcourse

Lili Bumbum (_flipout): since the cookie is already in the node
its false
the otherway round works fine

Mattias Jansson (mattias): what is the timeout?

Lili Bumbum (_flipout): 2000
rpc call fails as well
ahhh I might have an idea
the rcp fails with
wait i have to test it mom<
btw thanks for helping me

Mattias Jansson (mattias): np. but tell me if you find the answer ;)

Lili Bumbum (_flipout): dont go away<
the Nameserver cannot find the node on the server

Mattias Jansson (mattias): oh
try long names
erl -name “erl_node@127.0.0.1″ -setcookie cookie
_node = new OtpNode(“otp_node@127.0.0.1″, “cookie”);
no
_node = new OtpNode(“java_node@127.0.0.1″, “cookie”);
_node.ping(“erl_node@127.0.0.1″, 2000);
“The constructors for the OtpNode classes will create names exactly as you provide them as long as the name contains ‘@’. If the string you provide contains no ‘@’, it will be treated as an alivename and the name of the local host will be appended, resulting in a shortname.”

Lili Bumbum (_flipout): ok<
java.io.IOException: Nameserver not responding on fed when looking up master
here is the test code http://pastebin.com/y5Su0bkE

Mattias Jansson (mattias): replace “fed” by a real IP. 127.0.0.1 should be fine for now

Lili Bumbum (_flipout): its working I replaced -sname with -name and used a real ip and it worked

Mattias Jansson (mattias): nice!

Lili Bumbum (_flipout): do you know the reason why exactly the one sees the other but the other doesnt?
thanks a lot
Mattias Jansson (mattias): the thing is
the Java machine seems to need a real DNS to look up the address of the host name but if you use ip-adresses it’s not needed

Lili Bumbum (_flipout): good to know, again thanks!