Package anbxj
Class Channel_ExistingSocket
java.lang.Object
anbxj.Channel_Abstraction
anbxj.Channel_ExistingSocket
A channel implementation that wraps an already connected
Socket.
This class is used when a socket has been accepted by a server (or created by a client) outside the normal channel opening process. It delegates stream initialisation to the superclass and handles the closing of the underlying socket.
- See Also:
-
Field Summary
Fields inherited from class anbxj.Channel_Abstraction
cp -
Constructor Summary
ConstructorsConstructorDescriptionChannel_ExistingSocket(Socket socket, Channel_Properties cp) Constructs a new channel that uses the given already connected socket. -
Method Summary
Methods inherited from class anbxj.Channel_Abstraction
checkPort, getChannelRole, getChannelSettings, OpenStreams, Receive, Receive, safeReadObject, Send, setStep
-
Constructor Details
-
Channel_ExistingSocket
Constructs a new channel that uses the given already connected socket.- Parameters:
socket- the already connected socket (must be connected)cp- the channel properties (host, port, type, etc.) - may be used for debugging or configuration, but the socket itself is already established.- Throws:
NullPointerException- ifsocketorcpisnull
-
-
Method Details
-
Open
public void Open()Opens the channel by initialising the object streams on the underlying socket.This method calls
Channel_Abstraction.OpenStreams(Socket)to create theObjectInputStreamandObjectOutputStream. AnyThrowablethrown during stream creation is logged and then rethrown.- Overrides:
Openin classChannel_Abstraction- Throws:
RuntimeException- if an error occurs while opening the streams (the original exception is wrapped if necessary)
-
Close
public void Close()Closes the channel and the underlying socket.First calls
Channel_Abstraction.Close()to close the streams, then closes the socket itself. AnyIOExceptionduring socket close is logged but not rethrown.- Overrides:
Closein classChannel_Abstraction
-
getSerializer
-