public static OutPacketBuffer checkRevision(String versionString, int prod, String mpq, Long fileTime, String bnServer)
{
Socket bnSCK = null;
OutputStream out = null;
InputStream in = null;
OutPacketBuffer cacheHit = (OutPacketBuffer) crCache.get(versionString + mpq + prod + fileTime);
if(cacheHit != null) return cacheHit;
try {
bnSCK = new Socket(bnServer, 9367);
out = bnSCK.getOutputStream();
in = bnSCK.getInputStream();
OutPacketBuffer packet = new OutPacketBuffer(0x1A);
packet.add(prod);
packet.add((int)0);
packet.add((int)0);
packet.add(fileTime);
packet.addNTString(mpq);
packet.addNTString(versionString);
out.write(packet.getBuffer());
try {
short headlen;
int i;
i = in.read();
if (i == -1)
throw new IOException("Connection terminated. 1");
headlen = (short) ((i << 0) & 0x000000FF);
i = in.read();
if (i == -1)
throw new IOException("Connection terminated. 2");
headlen |= (short) ((i << 8) & 0x0000FF00);
i = in.read();
OutPacketBuffer header = new OutPacketBuffer(0x1A);
int bytesRead = 3;
while (bytesRead < headlen){
i = in.read();
if (i == -1)
throw new IOException("Connection terminated. " + bytesRead);
header.add((byte) i);
bytesRead++;
}
crCache.put(versionString + mpq + prod + fileTime, header);
return header;