How to start a conversation with a bonjour client, knowing his name @host: port?


I am working on a project for a P2P messenger, for example, ichat, but only for LAN.
I use the jmdns library to discover services and test pidgin and register as a Bonjour user. for now, the _presence._tcp.local service. well known
then we know the user information on the local network, for example, the name @host: port, and how to start a conversation with the Bonjour client?
I looked at XMPP but doesnโ€™t support P2P, but Iโ€™m unlikely to find a library for an extension that supports P2P.
maybe i should use sip to talk? but is the package format compatible with Bonjour? or do I need to study the structure of packet exchange?
Can someone explain a little about how ichat works on the local network?
Thanks so much for your kind help!

+4
source share
3 answers

I think you are a little confused.

Bonjour is a service search engine. This is not for communicating with the service. After you found the name @host: port information, you are done with Bonjour.

The next step will require you to talk about a protocol that the service understands. The _presence token in the service line indicates that it is an XMPP service. You will need to talk to XMPP. You cannot talk with SIP. Did you try to open an XMPP connection with the host and port you found?

You are talking about SIP and Jingle. They are used to set up an audio or video call. If you are writing an instant messenger, you do not need to do this. Only XMPP is enough.

If you want to support audio or video, you will need one of these protocols. Since the service you found is an XMPP service, you will need to use Jingle. If you do not have a library that can speak Jingle, you will have to write the code yourself. There is nothing in the Bonjour information that identifies the SIP service, so you cannot use SIP โ€” unless you can make another Bonjour request and find the SIP service.

I conclude that you are working in Java. The most popular XMPP library for Java is Smack .

+4
source

Thank you for your attention, now I have found something. XMPP does not support P2P mode, supports only client-server-clients. but there is another standard, โ€œXEP-0174: Serverless Messaging,โ€ which is suitable for p2p chat on a local network. DNS-SD + XEP-0174, ichat works this way.
since I used the smack library, it does not support p2P; but someone made some changes, here is the link http://issues.igniterealtime.org/browse/SMACK-262 .
I have not tried this XMPPLLConnection, I studied the source code for smack, it is based on socket connections. Unfortunately, there is no java library for XEP-1074, so I need to work with the xml stream through the socket.

+2
source

You can use SIP for this. MDNS will be your discovery mechanism, then you would use a simple SIP to call, the one you learned the URI that you want to dial.

SIPSIMPLE SDK (http://sipsimpleclient.com) implements this function by executing this expired project: http://tools.ietf.org/html/draft-lee-sip-dns-sd-uri-03 , this may be a good start.

Basically, your client will generate a URI, for example sip: random_stuff @ip: port, and then publish it along with the display name using MDNS. The application also scans MDNS for peers on the local network: for example, _sipuri._udp. Once you get the URI, you can just dial using SIP.

0
source

All Articles