English 中文(简体)
How to get port number for iPhone Chatting Application
原标题:

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 replace YOURDOMAIN 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 foo@gmail.com. My client performs the lookup that can be simulated with dig on the command line like this:

% dig +short -t SRV _xmpp-client._tcp.gmail.com.
20 0 5222 talk1.l.google.com.
20 0 5222 talk4.l.google.com.
5 0 5222 talk.l.google.com.
20 0 5222 talk3.l.google.com.
20 0 5222 talk2.l.google.com.

The result with the lowest priority number is 5 0 5222 talk.l.google.com., which means you open a TCP connection to talk.l.google.com on port 5222.

To make SRV queries from code, check out this answer, which relies on DNSServiceQueryRecord.

问题回答

Kraken s Openfire Properties Page has the port and domain information you need. Just re-use and try with your application.

5222 is the default port for XMPP, but your implementation may have a different one. To find out, you do a DNS server query for _xmpp-client._tcp.DOMAIN_Name, where you replace DOMAIN_Name with the domain you re trying to connect to(ex. gmail.com,google.com,yahoo.com). This will return 0+ records that have hostName/port combinations for how to connect. If you get 0 records back, assume port 5222.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签