Arduino-Unity Wifi communication

Hi! Programming beginner here looking for help.

Im trying to write a simple code for arduino and Unity3d that allows me to send and recieve a string from my arduino mega to unity 3d via wifi. I have connected a ESP8266-01 to my arduino and succesfully connected to my home wifi. Im using the EEPROM to store the data needed for the communication (IP, pass, SSID, etc).
This is my first attempt at any non-serial communication and I must admit Im way over my head here. Not sure which port i can/should use. Not sure if the IP is correct (using the one shown for my PC on my router)

Im basically looking for a short guide or sample code which allows back and forth string commuication.
There is a lot of stuff online like videos showing the result but not the code.

The portion (method) of my arduino code which is supposed start the communication looks like this:

while (true)   // just for testing, dont hate me  :D 
  {
String host = "192.168.0.220";
int hostPort = 25001;

    WiFiClient client;
    if (client.connect(host, hostPort)) {

      Serial.println("Connected to host server");
      client.println("hello");

      while (client.connected()) {
        if (client.available()) {
          String inputClient = client.readString();
          Serial.println(inputClient);
        }
        if (Serial.available() > 0)
        {
          String inputSerial = Serial.readString();  // reads and saves incoming string

          client.println(inputSerial);
          if (inputSerial == "disc")
          {
            break;
          }
        }
      }
      client.stop();
      Serial.println("Disconected");
    }
    else {
      Serial.println("Connection failed!");
      client.stop();
    }
    delay(5000);   //also just for testing
  }

Im also very unexperienced in Unity so any example codes in that part would be appreciated.

Thank you!

while (true)   // just for testing, dont hate me  :D

Why not? You clearly do not understand that the loop() function is already called in an infinite loop, but you are trying to do something overly-complex for your level of understanding.

      while (client.connected()) {
        if (client.available()) {

What is the client that would be connecting to this server?

PaulS:

while (true)   // just for testing, dont hate me  :D

Why not? You clearly do not understand that the loop() function is already called in an infinite loop, but you are trying to do something overly-complex for your level of understanding.

      while (client.connected()) {

if (client.available()) {



What is the client that would be connecting to this server?

The while function ist just the small part of the code for the communication. In my main function (loop) I scan for incomming serial commands. I already have that part figured out and working. Im sorry for not explaining this part more: After I connected to my wifi, I wish for this function to allow me to send a string back and forth.

the full function is:

void start()
{
  Serial.println("Connecting to Server: ");

  while (true)
  {
    WiFiClient client;
    if (client.connect(host, 80)) {

      Serial.println("Connected to host server");
      client.println("hello");

      while (client.connected()) {
        if (client.available()) {
          String inputClient = client.readString();
          Serial.println(inputClient);
        }
        if (Serial.available() > 0)
        {
          String inputSerial = Serial.readString();  // reads and saves incoming string

          client.println(inputSerial);
          if (inputSerial == "disc")
          {
            break;
          }
        }
      }
      client.stop();
      Serial.println("Disconected");
    }
    else {
      Serial.println("Connection failed!");
      client.stop();
    }
    delay(5000);
  }
}
//

As for your second question: The client would be the arduino itself trying to conect via client.connect(host, hostPort) to a server hosted by Unity3d on my PC.