@Override
	public void run()
	{
		while (!close)
		{
			SocketChannel socket = null;
			try
			{
				socket = this.socket.accept();
				socket.socket().setTcpNoDelay(true);
				socket.configureBlocking(true);
				socket.socket().setKeepAlive(true);
				socket.socket().setSoTimeout(WAIT_SOTIMEOUT);
				
				
				//get Input
				ByteBuffer buf = ByteBuffer.allocate(NETCONSTANTS.PACKAGELENGTH);
				if(socket.read(buf)<0)
				{
					sendError(RESPONCECODES.TIMEOUT, socket);
					continue;
				}
				// message validate
				
				int id = -1;
				int sharedSecredt = new Random().nextInt();
				int udpPort = -1;
				boolean recoRequest = false;
					
				buf.position(0);
				if (buf.get() == NETCONSTANTS.MAGIC_LOGIN_CODE)
				{
					//port
					udpPort = buf.getInt();
					
					//reco?
					switch (buf.get())
					{
					case NETCONSTANTS.CONNECT:
						recoRequest = false;
						
					break;
					
					case NETCONSTANTS.RECONNECT:
						recoRequest = true;
						id = buf.getInt();
						sharedSecredt = buf.getInt();
					break;

					default:
						sendError(RESPONCECODES.DATA_CORRUPTED, socket);
						continue;
					}

				} else
				{
					sendError(RESPONCECODES.DATA_CORRUPTED, socket);
				}// magiccode
				
				//tcp, udp socket create
				ConnectionInfo info = new ConnectionInfo(socket, udpPort, id, sharedSecredt);
				
				if(recoRequest)
				{
					this.ref.addReconnectRequest(info);
				}else
				{
					this.ref.addJoinRequest(info,buf);
				}
				
			} catch (SocketTimeoutException e)
			{
				continue;
			} catch (Exception e)
			{
				sendError(RESPONCECODES.DATA_CORRUPTED, socket);
			}
	
		}
		
	}