I am developing a chat application.
But Right now chatting is possible with only google because I know only google's port no.
xmppClient = [[XMPPClient alloc] init];
[xmppClient addDelegate:self];
// Replace me with the proper domain and port.
// The example below is setup for a typical google talk account.
[xmppClient setDomain:@"talk.google.com"];
[xmppClient setPort:5222];
You can see that, google has set 5222 as port number.
Same way I want to set port no for yahoo, windows messenger & other popular sites, How can I get all these?
(Is it something like that - "XMPP is specific for Google ones" ? ? )
5222/tcp is the default port for XMPP, but your implementation may have a different one. To find out, you do a DNS SRV query for
_xmpp-client._tcp.YOURDOMAIN
, where you replaceYOURDOMAIN
with the domain you're trying to connect to. This will return 0+ records that have hostname/port combinations for how to connect. If you get 0 records back, assume port 5222.For example, I want to connect to the GoogleTalk server, and log in with the account
[email protected]
. My client performs the lookup that can be simulated with dig on the command line like this:The result with the lowest priority number is
5 0 5222 talk.l.google.com.
, which means you open a TCP connection totalk.l.google.com
on port 5222.To make SRV queries from code, check out this answer, which relies on DNSServiceQueryRecord.