public class PseudoTcpSocket extends Socket
Modifier and Type | Field and Description |
---|---|
private Object |
closeLock |
private Object |
connectLock |
private PseudoTcpSocketImpl |
socketImpl |
Constructor and Description |
---|
PseudoTcpSocket(PseudoTcpSocketImpl socketImpl) |
Modifier and Type | Method and Description |
---|---|
void |
accept(int timeout)
Blocking method waits for connection.
|
void |
accept(SocketAddress remoteAddress,
int timeout)
Allows to set up the remote address directly.
|
private void |
checkDestination(int dstPort)
Checks destination port number.
|
void |
close() |
void |
connect(SocketAddress endpoint)
Connects without the timeout.
|
void |
connect(SocketAddress remoteAddr,
int timeout)
On Android, we must not use the default connect implementation,
because that one deals directly with physical resources, while we create
a socket on top of another socket.
|
long |
getConversationID() |
FileDescriptor |
getFileDescriptor()
Return the FileDescriptor of the underlying socket.
|
int |
getMTU()
Gets MTU (maximum transmission unit) value
|
long |
getOption(Option option)
Sets an
Option on this socket. |
PseudoTcpState |
getState()
Returns current PseudoTcpState of this socket
|
boolean |
isClosed() |
boolean |
isConnected() |
boolean |
isConnecting() |
void |
setConversationID(long convID)
Set conversation ID for the socket
Must be called on unconnected socket
|
void |
setDebugName(String debugName)
Sets debug name that will be displayed in log messages for this socket
|
void |
setMTU(int mtu)
Sets MTU (maximum transmission unit) value
|
void |
setOption(Option option,
long optValue) |
bind, getChannel, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
private final PseudoTcpSocketImpl socketImpl
private final Object connectLock
private final Object closeLock
PseudoTcpSocket(PseudoTcpSocketImpl socketImpl) throws SocketException
SocketException
public long getConversationID()
public void setConversationID(long convID) throws IllegalStateException
convID
- the conversation ID to setIllegalStateException
- when called on connected or closed socketpublic void setMTU(int mtu)
mtu
- the MTU valuepublic int getMTU()
public long getOption(Option option)
Option
on this socket.option
- the option to set on this socket.Option
public void setOption(Option option, long optValue)
option
- PseudoTCP option to setoptValue
- option's valueOption
public void accept(int timeout) throws IOException
timeout
- for this operation in msIOException
- If socket gets closed or timeout expirespublic void setDebugName(String debugName)
debugName
- the name of this socket for debug messagespublic PseudoTcpState getState()
PseudoTcpState
public boolean isConnected()
isConnected
in class Socket
public boolean isConnecting()
public void connect(SocketAddress endpoint) throws IOException
connect
in class Socket
IOException
private void checkDestination(int dstPort)
dstPort
- the destination port to check.public void connect(SocketAddress remoteAddr, int timeout) throws IOException
connect
in class Socket
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Socket
IOException
public void accept(SocketAddress remoteAddress, int timeout) throws IOException
remoteAddress
- the one and only remote address that will be
accepted as remote packet's sourcetimeout
- connection accept timeout value in milliseconds, after
which the exception will be thrown.IOException
- if socket is closed or timeout expirespublic FileDescriptor getFileDescriptor()
Copyright © 2018. All rights reserved.