File tree 2 files changed +29
-0
lines changed
libraries/ESP8266WiFi/src 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,34 @@ void WiFiServer::begin() {
82
82
tcp_arg (listen_pcb, (void *) this );
83
83
}
84
84
85
+ void WiFiServer::begin (uint16_t port) {
86
+ close ();
87
+ _port = port;
88
+ err_t err;
89
+ tcp_pcb* pcb = tcp_new ();
90
+ if (!pcb)
91
+ return ;
92
+
93
+ ip_addr_t local_addr;
94
+ local_addr.addr = (uint32_t ) _addr;
95
+ pcb->so_options |= SOF_REUSEADDR;
96
+ err = tcp_bind (pcb, &local_addr, _port);
97
+
98
+ if (err != ERR_OK) {
99
+ tcp_close (pcb);
100
+ return ;
101
+ }
102
+
103
+ tcp_pcb* listen_pcb = tcp_listen (pcb);
104
+ if (!listen_pcb) {
105
+ tcp_close (pcb);
106
+ return ;
107
+ }
108
+ _pcb = listen_pcb;
109
+ tcp_accept (listen_pcb, &WiFiServer::_s_accept);
110
+ tcp_arg (listen_pcb, (void *) this );
111
+ }
112
+
85
113
void WiFiServer::setNoDelay (bool nodelay) {
86
114
_noDelay = nodelay;
87
115
}
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ class WiFiServer : public Server {
51
51
WiFiClient available (uint8_t * status = NULL );
52
52
bool hasClient ();
53
53
void begin ();
54
+ void begin (uint16_t port);
54
55
void setNoDelay (bool nodelay);
55
56
bool getNoDelay ();
56
57
virtual size_t write (uint8_t );
You can’t perform that action at this time.
0 commit comments