public class AprSocketContext extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
AprSocketContext.BlockingPollHandler
Callback for poll events, will be invoked in a thread pool.
|
static interface |
AprSocketContext.HostInfoLoader
Delegates loading of persistent info about a host - public certs,
tickets, config, persistent info etc.
|
static interface |
AprSocketContext.NonBlockingPollHandler
Additional callbacks for non-blocking.
|
static interface |
AprSocketContext.RawDataHandler
Called when a chunk of data is sent or received.
|
static interface |
AprSocketContext.TlsCertVerifier
Called in SSL mode after the handshake is completed.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
running |
protected boolean |
sslMode |
Constructor and Description |
---|
AprSocketContext() |
Modifier and Type | Method and Description |
---|---|
protected long |
allocatePoller(int size,
long pool) |
protected void |
connectBlocking(AprSocket apr) |
void |
customVerification(AprSocketContext.TlsCertVerifier verifier) |
protected void |
finalize()
To clean the pools - we could track if all channels are
closed, but this seems simpler and safer.
|
int |
getBacklog() |
boolean |
getDeferAccept() |
protected Executor |
getExecutor() |
HostInfo |
getHostInfo(String host,
int port,
boolean ssl)
Override or use hostInfoLoader to implement persistent/memcache storage.
|
int |
getPollerThreadCount() |
String |
getSSLCipherSuite() |
boolean |
isServer() |
void |
listen(int port) |
protected void |
onSocket(AprSocket s)
Called on each accepted socket (for servers) or after connection (client)
after handshake.
|
protected void |
rawData(AprSocket ch,
boolean inp,
byte[] data,
int pos,
int len,
int requested,
boolean closed) |
void |
setBacklog(int backlog) |
void |
setDeferAccept(boolean deferAccept)
Defer accept.
|
void |
setHostLoader(AprSocketContext.HostInfoLoader handler) |
AprSocketContext |
setKeys(String certPemFile,
String keyDerFile)
Set certificate, will also enable TLS mode.
|
void |
setMaxconnections(int maxCon) |
void |
setNpn(byte[] data) |
void |
setNpn(String npn)
For client:
- ClientHello will include the npn extension ( the ID == 0x3374)
- if ServerHello includes a list of protocols - select one
- send it after ChangeCipherSpec and before Finish
For server:
- if ClientHello includes the npn extension
-- will send this string as list of supported protocols in ServerHello
- read the selection before Finish.
|
void |
setPollerThreadCount(int pollerThreadCount) |
void |
setSSLCipherSuite(String SSLCipherSuite) |
void |
setSslProtocol(String protocol) |
void |
setTcpNoDelay(boolean b) |
void |
setTicketKey(byte[] key48Bytes) |
AprSocketContext |
setTls()
All accepted/connected sockets will start handshake automatically.
|
AprSocket |
socket(HostInfo hi) |
AprSocket |
socket(long socket) |
AprSocket |
socket(String host,
int port,
boolean ssl)
Get a socket for connectiong to host:port.
|
void |
stop() |
public void setPollerThreadCount(int pollerThreadCount)
public int getPollerThreadCount()
public void setMaxconnections(int maxCon)
public void setBacklog(int backlog)
public int getBacklog()
public void setDeferAccept(boolean deferAccept)
public boolean getDeferAccept()
public void setNpn(String npn)
npn
- public void setNpn(byte[] data)
public void setHostLoader(AprSocketContext.HostInfoLoader handler)
public boolean isServer()
protected Executor getExecutor()
public AprSocketContext setTls()
public void setTcpNoDelay(boolean b)
public void setSslProtocol(String protocol)
public void setTicketKey(byte[] key48Bytes)
public void customVerification(AprSocketContext.TlsCertVerifier verifier)
public AprSocketContext setKeys(String certPemFile, String keyDerFile)
public String getSSLCipherSuite()
public void setSSLCipherSuite(String SSLCipherSuite)
public HostInfo getHostInfo(String host, int port, boolean ssl)
protected void rawData(AprSocket ch, boolean inp, byte[] data, int pos, int len, int requested, boolean closed)
public void listen(int port) throws IOException
IOException
public AprSocket socket(String host, int port, boolean ssl)
public AprSocket socket(long socket)
protected void connectBlocking(AprSocket apr) throws IOException
IOException
protected void finalize() throws Throwable
public void stop()
protected void onSocket(AprSocket s)
protected long allocatePoller(int size, long pool)
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.