aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-30 16:13:30 +0300
committerGravatar Vitaly Takmazov2016-01-30 16:13:30 +0300
commit474323453f1b881273f618555845e07ace830bd2 (patch)
tree11673a80973b3fb493912edc366ade720ecf40c4 /src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
parent58fb4a6394cb19ee04e65d0e921cdf0ae6fdb6e3 (diff)
s2s: NIO.2 sockets
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s/ConnectionOut.java')
-rw-r--r--src/main/java/com/juick/xmpp/s2s/ConnectionOut.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java b/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
index 0205349a..8e543843 100644
--- a/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
+++ b/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java
@@ -4,7 +4,11 @@ import com.juick.xmpp.utils.XmlUtils;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.net.InetSocketAddress;
import java.net.Socket;
+import java.nio.channels.AsynchronousSocketChannel;
+import java.nio.channels.Channels;
+
import org.xmlpull.v1.XmlPullParser;
/**
@@ -36,10 +40,11 @@ public class ConnectionOut extends Connection implements Runnable {
try {
HostnamePort addr = DNSQueries.getServerAddress(to);
- socket = new Socket(addr.hostname, addr.port);
+ socket = AsynchronousSocketChannel.open();
+ socket.connect(new InetSocketAddress(addr.hostname, addr.port));
- parser.setInput(new InputStreamReader(socket.getInputStream()));
- writer = new OutputStreamWriter(socket.getOutputStream());
+ parser.setInput(new InputStreamReader(Channels.newInputStream(socket)));
+ writer = new OutputStreamWriter(Channels.newOutputStream(socket));
sendStanza("<?xml version='1.0'?><stream:stream xmlns='jabber:server' " +
"xmlns:stream='http://etherx.jabber.org/streams' xmlns:db='jabber:server:dialback' from='" +