Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_CLIENT_DATA_PORT |
protected ServerSocketFactory |
serverSocketFactory |
protected SocketFactory |
socketFactory |
Constructor and Description |
---|
DefaultSession(Socket controlSocket,
Map commandHandlers)
Create a new initialized instance
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the session, closing the underlying sockets
|
void |
closeDataConnection()
Close the data connection
|
Object |
getAttribute(String name)
Return the attribute value for the specified name.
|
Set |
getAttributeNames()
Return the Set of names under which attributes have been stored on this session.
|
InetAddress |
getClientHost()
Return the InetAddress representing the client host for this session
|
InetAddress |
getServerHost()
Return the InetAddress representing the server host for this session
|
boolean |
isClosed() |
void |
openDataConnection()
Open the data connection, attaching to the predefined port number on the client
|
byte[] |
readData()
Read data from the client across the data connection
|
byte[] |
readData(int numBytes)
Read and return (up to) numBytes of data from the client across the data connection
|
void |
removeAttribute(String name)
Remove the attribute value for the specified name.
|
void |
run() |
void |
sendData(byte[] data,
int numBytes)
Write the specified data using the data connection
|
void |
sendReply(int code,
String text)
Send the specified reply code and text across the control connection.
|
void |
setAttribute(String name,
Object value)
Store the value under the specified attribute name.
|
void |
setClientDataHost(InetAddress clientHost) |
void |
setClientDataPort(int dataPort) |
int |
switchToPassiveMode()
Switch to passive mode
|
protected static final int DEFAULT_CLIENT_DATA_PORT
protected SocketFactory socketFactory
protected ServerSocketFactory serverSocketFactory
public DefaultSession(Socket controlSocket, Map commandHandlers)
controlSocket
- - the control connection socketcommandHandlers
- - the Map of command name : CommandHandler. It is assumed that the
command names are all normalized to upper case. See Command.normalizeName(String)
.public InetAddress getClientHost()
getClientHost
in interface Session
Session.getClientHost()
public InetAddress getServerHost()
getServerHost
in interface Session
Session.getServerHost()
public void sendReply(int code, String text)
public void openDataConnection()
Session
openDataConnection
in interface Session
Session.openDataConnection()
public int switchToPassiveMode()
switchToPassiveMode
in interface Session
Session.switchToPassiveMode()
public void closeDataConnection()
Session
closeDataConnection
in interface Session
Session.closeDataConnection()
public void close()
Session
close
in interface Session
Session.close()
public void sendData(byte[] data, int numBytes)
Session
sendData
in interface Session
data
- - the data to writenumBytes
- - the number of bytes from data to sendSession.sendData(byte[], int)
public byte[] readData()
Session
readData
in interface Session
Session.readData()
public byte[] readData(int numBytes)
Session
readData
in interface Session
numBytes
- - the maximum number of bytes to readSession.readData()
public void setClientDataHost(InetAddress clientHost)
setClientDataHost
in interface Session
clientHost
- - the client host for the data connectionSession.setClientDataHost(java.net.InetAddress)
public void setClientDataPort(int dataPort)
setClientDataPort
in interface Session
dataPort
- - the port number on the client side for the data connectionSession.setClientDataPort(int)
public void run()
run
in interface Runnable
Runnable.run()
public Object getAttribute(String name)
getAttribute
in interface Session
name
- - the attribute name; may not be nullSession.getAttribute(java.lang.String)
public void setAttribute(String name, Object value)
setAttribute
in interface Session
name
- - the attribute name; may not be nullvalue
- - the attribute value; may be nullSession.setAttribute(java.lang.String, java.lang.Object)
public Set getAttributeNames()
getAttributeNames
in interface Session
Session.getAttributeNames()
public void removeAttribute(String name)
removeAttribute
in interface Session
name
- - the attribute name; may not be nullAssertFailedException
- - if name is nullSession.removeAttribute(java.lang.String)
Copyright © 2016. All rights reserved.