/* Sets the state and callback handler of the given port, specified in big endian to the given state. */
bool TCP_SetPortState(const uint16_t Port, const uint8_t State, void(*Handler)(TCP_ConnectionState_t *, TCP_ConnectionBuffer_t *))
/* Sets the state and callback handler of the given port, specified in big endian to the given state. */
bool TCP_SetPortState(const uint16_t Port, const uint8_t State, void(*Handler)(TCP_ConnectionState_t *, TCP_ConnectionBuffer_t *))
{
	for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++)
	{
		if (PortStateTable[PTableEntry].Port == Port)
		{
			PortStateTable[PTableEntry].State = State;
			PortStateTable[PTableEntry].ApplicationHandler = Handler;
			return true;
		}
	}
	if (State == TCP_Port_Open)
	{
		for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++)
		{
			if (PortStateTable[PTableEntry].State == TCP_Port_Closed)
			{
				PortStateTable[PTableEntry].Port  = Port;
				PortStateTable[PTableEntry].State = State;
				PortStateTable[PTableEntry].ApplicationHandler = Handler;
				return true;
			}
		}
		return false;
	}
	else
	{
		return true;
	}
}