Class Connection
- All Implemented Interfaces:
PacketReceiver<SMBPacketData<?>>, Closeable, AutoCloseable
public class Connection
extends Pooled<Connection>
implements Closeable, PacketReceiver<SMBPacketData<?>>
A connection to a server.
-
Constructor Summary
ConstructorsConstructorDescriptionConnection(Connection connection) Connection(SmbConfig config, SMBClient client, SMBEventBus bus, ServerList serverList) -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(AuthenticationContext authContext) Authenticate the user on this connection in order to start a (new) session.voidclose()voidclose(boolean force) Close the Connection.voidReturns the negotiated protocol details for this connection.voidhandle(SMBPacketData<?> uncheckedPacket) voidboolean<T extends SMB2Packet>
Future<T> send(SMB2Packet packet) send a packet.voidsetMessageConverter(SMB2MessageConverter smb2Converter)
-
Constructor Details
-
Connection
-
Connection
-
-
Method Details
-
getClient
-
connect
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
close
Close the Connection. Ifforceis set to true, it forgoes theSession.close()operation on the open sessions, and it just calls theTransportLayer.disconnect().If
forceis set to false, the usage counter of the connection reduces with one. If the usage count drops to zero the connection will be closed.- Parameters:
force- if set, does not nicely terminate the open sessions.- Throws:
IOException- If any error occurred during close-ing.
-
authenticate
Authenticate the user on this connection in order to start a (new) session.- Returns:
- a (new) Session that is authenticated for the user.
-
send
send a packet.- Parameters:
packet- SMBPacket to send- Returns:
- a Future to be used to retrieve the response packet
- Throws:
TransportException- When a transport level error occurred
-
getNegotiatedProtocol
Returns the negotiated protocol details for this connection.- Returns:
- The negotiated protocol details
-
handle
- Specified by:
handlein interfacePacketReceiver<SMBPacketData<?>>- Throws:
TransportException
-
handleError
- Specified by:
handleErrorin interfacePacketReceiver<SMBPacketData<?>>
-
getRemoteHostname
-
isConnected
public boolean isConnected() -
getConnectionContext
-
setMessageConverter
-