Skip to content

Commit 81a5c68

Browse files
committed
expose socket object.
fix readString on ByteBufferList. Change-Id: I07993c7354432d32b25de1e7b9c097c16ac99a4a
1 parent bd2dc1a commit 81a5c68

8 files changed

+35
-9
lines changed

AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.koushikdutta.async;
22

3-
import android.util.Log;
4-
53
import java.io.IOException;
64
import java.net.InetSocketAddress;
7-
import java.net.SocketAddress;
85
import java.nio.ByteBuffer;
96

107
public class AsyncDatagramSocket extends AsyncNetworkSocket {

AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.koushikdutta.async;
22

33
import android.util.Log;
4+
45
import com.koushikdutta.async.callback.CompletedCallback;
56
import com.koushikdutta.async.callback.DataCallback;
67
import com.koushikdutta.async.callback.WritableCallback;
@@ -350,4 +351,8 @@ public InetSocketAddress getRemoteAddress() {
350351
public int getLocalPort() {
351352
return mChannel.getLocalPort();
352353
}
354+
355+
public Object getSocket() {
356+
return getChannel().getSocket();
357+
}
353358
}

AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocketWrapper.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
package com.koushikdutta.async;
22

33
import android.os.Build;
4+
45
import com.koushikdutta.async.callback.CompletedCallback;
56
import com.koushikdutta.async.callback.DataCallback;
67
import com.koushikdutta.async.callback.WritableCallback;
78
import com.koushikdutta.async.wrapper.AsyncSocketWrapper;
9+
810
import org.apache.http.conn.ssl.StrictHostnameVerifier;
911

10-
import javax.net.ssl.*;
11-
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
12-
import javax.net.ssl.SSLEngineResult.Status;
1312
import java.nio.ByteBuffer;
1413
import java.security.KeyStore;
1514
import java.security.cert.X509Certificate;
1615

16+
import javax.net.ssl.HostnameVerifier;
17+
import javax.net.ssl.SSLContext;
18+
import javax.net.ssl.SSLEngine;
19+
import javax.net.ssl.SSLEngineResult;
20+
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
21+
import javax.net.ssl.SSLEngineResult.Status;
22+
import javax.net.ssl.SSLException;
23+
import javax.net.ssl.TrustManager;
24+
import javax.net.ssl.TrustManagerFactory;
25+
import javax.net.ssl.X509TrustManager;
26+
1727
public class AsyncSSLSocketWrapper implements AsyncSocketWrapper, AsyncSSLSocket {
1828
AsyncSocket mSocket;
1929
BufferedDataEmitter mEmitter;

AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ public String readString() {
329329
builder.append(new String(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining()));
330330
reclaim(bb);
331331
}
332+
remaining = 0;
332333
return builder.toString();
333334
}
334335

AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ public void close() throws IOException {
4747
}
4848

4949
public abstract int getLocalPort();
50+
public abstract Object getSocket();
5051
}

AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.koushikdutta.async;
22

3-
import android.util.Log;
4-
53
import java.io.IOException;
64
import java.net.InetSocketAddress;
7-
import java.net.SocketAddress;
85
import java.nio.ByteBuffer;
96
import java.nio.channels.ClosedChannelException;
107
import java.nio.channels.DatagramChannel;
@@ -86,4 +83,9 @@ public long read(ByteBuffer[] byteBuffers) throws IOException {
8683
public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
8784
return mChannel.read(byteBuffers, i, i2);
8885
}
86+
87+
@Override
88+
public Object getSocket() {
89+
return mChannel.socket();
90+
}
8991
}

AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,9 @@ public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
7373
assert false;
7474
throw new IOException(msg);
7575
}
76+
77+
@Override
78+
public Object getSocket() {
79+
return mChannel.socket();
80+
}
7681
}

AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ public long read(ByteBuffer[] byteBuffers) throws IOException {
6767
public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
6868
return mChannel.read(byteBuffers, i, i2);
6969
}
70+
71+
@Override
72+
public Object getSocket() {
73+
return mChannel.socket();
74+
}
7075
}

0 commit comments

Comments
 (0)