How does xmpp s2s work?

I have had hard time understanding the complete information flow in s2s interaction. There aren't many documents available on internet.

I am using nodejs based xmpp-server to set up a xmpp server which is built on top of node-xmpp. This is working perfectly for a single server system but development hasn't been done in "xmpp-server" module for s2s support. Packages like ejabberd do support s2s but there isn't much documentation available on to how this whole thing works.

Another thing to note is that I don't want multiple host names. All I want is another instance of the xmpp server that I am already running on one machine. Both can use the same database.

http://xmpp.org/rfcs/rfc6120.html#examples-s2s Complete example using tls and certificates. The document specify the core XMPP protocol so you should found answers to most of your questions there.

http://xmpp.org/extensions/xep-0220.html DNS Dialback protocol, if s2s authentication isn't performed using certificates you will need this.