- All Superinterfaces:
AutoCloseable
,Closeable
This is the public interface to
ISocketWrapper
, whose
purpose is to make our lives easier when working with Socket
.
Created to provide better testing access-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
Send the data in the outgoing buffer into the socket.The hostname of the server, as set in the configuration file of key HOST_NAME inConstants.hostName
Returns this socket's input stream for more granular accessint
Get the port of the serverReturns a string of the remote host address without portReturns aSocketAddress
, which includes the client's address and portvoid
send
(byte[] bodyContents) Simply send the bytes on the socket, simple as that.void
send
(byte[] bodyContents, int off, int len) void
send
(int b) void
Convert the provided string value into bytes using the default charset, and send on the socket.void
sendHttpLine
(String msg) Sends a line of text, with carriage-return and line-feed appended to the end, required for the HTTP protocol.
-
Method Details
-
send
Convert the provided string value into bytes using the default charset, and send on the socket.- Throws:
IOException
-
send
Simply send the bytes on the socket, simple as that.- Throws:
IOException
-
send
- Throws:
IOException
-
send
- Throws:
IOException
-
sendHttpLine
Sends a line of text, with carriage-return and line-feed appended to the end, required for the HTTP protocol.- Throws:
IOException
-
getLocalPort
int getLocalPort()Get the port of the server -
getRemoteAddrWithPort
SocketAddress getRemoteAddrWithPort()Returns aSocketAddress
, which includes the client's address and port -
getRemoteAddr
String getRemoteAddr()Returns a string of the remote host address without port -
getServerType
HttpServerType getServerType() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getInputStream
InputStream getInputStream()Returns this socket's input stream for more granular access -
getHostName
String getHostName()The hostname of the server, as set in the configuration file of key HOST_NAME inConstants.hostName
-
flush
Send the data in the outgoing buffer into the socket.- Throws:
IOException
-