@Override
	public void run() {
		try {

			Socket receiveSocket = serverSocket.accept();

			JFileChooser fileChooser = new JFileChooser();
			fileChooser.setSelectedFile(new File(fileName));
			if (fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
				File file = fileChooser.getSelectedFile();
				path = file.getAbsolutePath();
				// save to file
			}
			DataInputStream in = new DataInputStream(
					receiveSocket.getInputStream());
			DataOutputStream out = new DataOutputStream(
					receiveSocket.getOutputStream());
			String startMessage = in.readUTF();

			ObjectInputStream inFile = new ObjectInputStream(receiveSocket.getInputStream());
			if (startMessage.equals(Tags.FILE_DATA_BEGIN)) {
				byte[] b = (byte[]) inFile.readObject();
				int length = b.length;
				ProtocolFileData metaData = Communicate.getFileDataInBinary(b, length);
				while (!metaData.isEnd()) {
					receiveListInBytes.add(metaData.getContent());
					b = (byte[]) inFile.readObject();
					metaData = Communicate.getFileDataInBinary(b, b.length);
				}

				length = (receiveListInBytes.size() - 1)
						* 1024
						+ receiveListInBytes.get(receiveListInBytes.size() - 1).length;
				byte[] lego = new byte[length];
				int offset = 0;
				for (byte[] bytes : receiveListInBytes) {
					System.arraycopy(bytes, 0, lego, offset, bytes.length);
					offset += bytes.length;
				}
				dataFile = lego;
			}

			// save file
			JOptionPane.showMessageDialog(null, "File was transfered.");

			// save file
			FileOutputStream fos = new FileOutputStream(path);
			fos.write(dataFile);
			fos.close();

		} catch (IOException | TagFormatException | ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}