Hi,
opening a communication channel is like picking up the phone and calling
someone. If the number is valid, someone may anwer the call from the other
end.
Now, to find out if the other end understands english, you are supposed to
say at least "hello". While in the real world the remote person may speak to
you, with sockets, ports and servers one can not rely on such a behaviour,
instead quite often the client / caller is supposed to say something on
which the other end then reacts.
Lastly, even if the number is right and the other end is willing to speak
english (or "framed binary" as a Thrift example), it may still have no clue
about your request. Since you called your local "butcher" service, the
server will not be able to give much advice about your car problems. Because
for that you will have to call another "number" where there is a "cars
fixing service".
To sum up: we have
a) a communication device - the socket/port is served
b) a communication protocol - it is a Thrift service able to understand our
expected "framed binary" lingo
c) a common topic - the service offered by the remote end, i.e. the "butcher
service" or the "cars fixing service"
So even if we manage to get a) and b) right - we still may not not what c)
services are supported, unless we do a call and see what we get in return.
What could be done instead is to solve the problem at another level of the
application. There are other systems available designed to provide resource
directories, like an electronic version of the yellow pages for services.
IIRC ZooKeeper can do that, but there is certainly a plethora of other
systems that might be an even better fit.
Bottom line: Scanning ports is not a quite efficient strategy w/regard to
scalability.
Have fun,
JensG
-----Ursprüngliche Nachricht-----
From: Gianni Ambrosio
Sent: Thursday, May 14, 2020 4:24 PM
To: user@thrift.apache.org
Subject: how to check if there is a thrift service behind a certain port?
Dear All,
In my application I scan a subnet to find all PCs where a thrift service
is active on a certain port.
Unfortunately if the port is open by another service (not a thrift
service) the transport->open() call succeeded. I thought the open() call
would have failed in this case. The problem is that every call to the
thrift service throws an exception when the open succeeds but there
isn't any thrift service behind. It would be nice to know on open if a
thrift service exists. Is there a way?
Cheers,
Gianni