MiddleServerSocket(SharedData s) {
		sharedData = s;
		try {
			serverSocketChannel = ServerSocketChannel.open();
			serverSocketChannel.socket().bind(
					new InetSocketAddress(s.getMiddlePortNum()));
			serverSocketChannel.configureBlocking(false);
		} catch (IOException e) {
			e.printStackTrace();
		}
		dir = new File(sharedData.getFilePathName() + "/Transactions");
		if (!dir.exists()) {
			dir.mkdirs();
		}

		numWorkers = sharedData.getNumWorkers();
		try {
			sharedData.selector = Selector.open();
		} catch (IOException e) {
			e.printStackTrace();
		}
		sharedData.keyIterator = sharedData.selector.selectedKeys().iterator();
		workers = new MiddleWorker[numWorkers];
		for (int i = 0; i < numWorkers; ++i) {
			workers[i] = new MiddleWorker(sharedData);
			workers[i].start();
		}

		sharedData.socketMap = new HashMap<SocketChannel, MiddleSocketChannel>();

	}