#ifndef TCPSERVER_H
#define TCPSERVER_H

#include<HardwareSerial.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include<WiFi.h>
#endif

#define MAX_SRV_CLIENTS 2
class TCPserver
{
private:
    /* data */
    //创建server 端口号是23
    WiFiServer *server;
//管理clients
    WiFiClient serverClients[MAX_SRV_CLIENTS];
  
    bool isPortOutInit;
 
public:


#if ARDUINO_USB_CDC_ON_BOOT && !ARDUINO_USB_MODE //Serial used for USB CDC
    USBCDC *myserial;
        TCPserver(USBCDC *serial,int port);
#elif ARDUINO_USB_CDC_ON_BOOT && ARDUINO_USB_MODE
    HWCDC *myserial;
        TCPserver(HWCDC *serial,int port);
#else
    HardwareSerial *myserial;
        TCPserver(HardwareSerial *serial,int port);
#endif



     TCPserver(int port);
     void initme();
    ~TCPserver();
    void SendDataToClinet(String str,int clinetid=-1);
   void SendDataToClinet(char *str,int clinetid=-1);
    void loop();
    
};

#endif

