freeConnection(connectionSession);
}
private static void doSendMagicAndCheckVersions(final Connection connection) throws IOException, VersionMismatchException {
final VersionController versionController = VersionController.getInstance();
final Version framingVersion = versionController.getFramingVersion();
final Version connectionManagementVersion = versionController.getConnectionManagementVersion();
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, MessagesMessages.WSTCP_1040_CONNECTION_MANAGER_DO_CHECK_VERSION_ENTER(framingVersion, connectionManagementVersion));
}
connection.setDirectMode(true);
final OutputStream outputStream = connection.openOutputStream();
outputStream.write(TCPConstants.PROTOCOL_SCHEMA.getBytes("US-ASCII"));
DataInOutUtils.writeInts4(outputStream, framingVersion.getMajor(),
framingVersion.getMinor(),
connectionManagementVersion.getMajor(),
connectionManagementVersion.getMinor());
connection.flush();
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, MessagesMessages.WSTCP_1041_CONNECTION_MANAGER_DO_CHECK_VERSION_SENT());
}
final InputStream inputStream = connection.openInputStream();
final int[] versionInfo = new int[4];
DataInOutUtils.readInts4(inputStream, versionInfo, 4);
final Version serverFramingVersion = new Version(versionInfo[0], versionInfo[1]);
final Version serverConnectionManagementVersion = new Version(versionInfo[2], versionInfo[3]);
connection.setDirectMode(false);
final boolean success = versionController.isVersionSupported(serverFramingVersion, serverConnectionManagementVersion);