-->
Page 2 of 2

Re: ESP8266 - Catch incoming TCP SYN / ACK packets

PostPosted: Sat Aug 12, 2017 11:00 am
by tele_player
This works here, on 8266 and ESP32. I wrote a simple client for it on Raspberry Pi. Obviously, WiFi.begin() and server.begin() must be called in setup().


Code: Select allvoid loop() {
  char buf[128];
  int ix = 0;
  unsigned char foo[4] = {0x0, 0x4, 0x85, 0x34};
 
  if (server.hasClient()) {       // new connection available
    client = server.available();  // accept connection
  } else {   
    delay(100);
    return;
  }

  // send {0x0, 0x4, 0x85, 0x34}; greeting
  client.write(&foo[0], 4);
  Serial.println("sent {0x0, 0x4, 0x85, 0x34}");

  // wait for client to send something
  while (!client.available()) {
    ;
  }
  // read bytes from client
  while(client.available()) {
    buf[ix++] = client.read();
  }
  buf[ix] = 0;

  // print text from client
  Serial.println(buf);
  delay(1000);

}