- 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 TypeMethodDescriptionvoidclose()voidflush()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.hostNameReturns this socket's input stream for more granular accessintGet the port of the serverReturns a string of the remote host address without portReturns aSocketAddress, which includes the client's address and portvoidsend(byte[] bodyContents) Simply send the bytes on the socket, simple as that.voidsend(byte[] bodyContents, int off, int len) voidsend(int b) voidConvert the provided string value into bytes using the default charset, and send on the socket.voidsendHttpLine(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:
closein interfaceAutoCloseable- Specified by:
closein 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
-