os.write(3);
Socket virtualSocket1 = mss.accept();
Socket virtualSocket2 = mss.accept();
int localPort = virtualSocket2.getLocalPort();
log.info("VirtualServerSocket binding to port: " + localPort);
vss = new VirtualServerSocket(localPort);
os.write(5);
Socket virtualSocket3 = vss.accept();
DataOutputStream vos = new DataOutputStream(virtualSocket3.getOutputStream());
vos.writeInt(localPort);
virtualSocket1.close();
virtualSocket2.close();
virtualSocket3.close();
mss.close();
vss.close();
break;
case RUN_SERVER_TIMEOUT_TEST:
Socket virtualSocket4 = null;
Socket virtualSocket5 = null;
Socket virtualSocket6 = null;
Socket virtualSocket7 = null;
mss = new MasterServerSocket(basicBehaviorServerPort + 100);
mss.setSoTimeout(10000);
os.write(3);
Thread.sleep(1000);
try
{
virtualSocket4 = mss.accept();
log.info("accepted virtualSocket4");
}
catch(SocketTimeoutException e)
{
log.info(e);
}
try
{
virtualSocket5 = mss.accept();
log.info("accepted virtualSocket5");
}
catch(SocketTimeoutException e)
{
log.info("timed out waiting to accept virtualSocket5");
}
is.read();
Thread.sleep(1000);
vss = new VirtualServerSocket(basicBehaviorServerPort + 101);
SocketAddress address1 = new InetSocketAddress(clientServerSocketHost, clientServerSocketPort + 101);
vss.connect(address1);
os.write(5);
Thread.sleep(1000);
vss.setSoTimeout(10000);
try
{
virtualSocket6 = vss.accept();
log.info("accepted virtualSocket6");
}
catch(SocketTimeoutException e)
{
log.info(e);
}
try
{
virtualSocket7 = vss.accept();
log.info("accepted virtualSocket7");
}
catch(SocketTimeoutException e)
{
log.info(e);
}
if(virtualSocket4 != null)
{
virtualSocket4.close();
}
if(virtualSocket5 != null)
{
virtualSocket5.close();
}
if(virtualSocket6 != null)
{
virtualSocket6.close();
}
if(virtualSocket7 != null)
{
virtualSocket7.close();
}
mss.close();
vss.close();
break;
case RUN_VSS_TO_VSS:
mss = new MasterServerSocket(++nextBindPort);
log.info("MasterServerSocket accepting connections on: " + nextBindPort);
os.write(3);
// int port = mss.acceptServerSocketConnection().getSocket().getLocalPort();
int port = mss.acceptServerSocketConnection();
vss = new VirtualServerSocket(port);
InetSocketAddress address = new InetSocketAddress(clientServerSocketHost, ++nextRemotePort);
is.read();
log.info("VirtualServerSocket connecting to port: " + nextRemotePort);
vss.connect(address);
log.info("VirtualServerSocket accepting connections on: " + nextBindPort);
os.write(7);
Socket virtualSocket8 = vss.accept();
log.info("first virtual socket created");
InputStream is8 = virtualSocket8.getInputStream();
OutputStream os8 = virtualSocket8.getOutputStream();
log.info("second virtual socket connecting to port: " + nextRemotePort);
Socket virtualSocket9 = new VirtualSocket(clientServerSocketHost, nextRemotePort);
log.info("second virtual socket created");
InputStream is9 = virtualSocket9.getInputStream();
OutputStream os9 = virtualSocket9.getOutputStream();
os8.write(is8.read());
os9.write(is9.read());
virtualSocket8.close();
virtualSocket9.close();
vss.close();
mss.close();
break;
case RUN_LONG_MESSAGE_TEST:
vss = new VirtualServerSocket(((VirtualSocket)testSocket).getLocalPort());
log.info("VirtualServerSocket accepting connections on: " + nextBindPort);
os.write(3);
final Socket virtualSocket10 = vss.accept();
final Socket virtualSocket11 = vss.accept();
final Socket virtualSocket12 = vss.accept();