File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ uint8_t WiFiUDP::begin(uint16_t port)
46
46
addr.sin_port = _htons (port);
47
47
addr.sin_addr .s_addr = 0 ;
48
48
49
+ if (_socket != -1 && WiFiSocket.bound (_socket)) {
50
+ WiFiSocket.close (_socket);
51
+ _socket = -1 ;
52
+ }
53
+
49
54
// Open UDP server socket.
50
55
if ((_socket = WiFiSocket.create (AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
51
56
return 0 ;
Original file line number Diff line number Diff line change @@ -172,6 +172,13 @@ uint8 WiFiSocketClass::listening(SOCKET sock)
172
172
return (_info[sock].state == SOCKET_STATE_LISTENING);
173
173
}
174
174
175
+ uint8 WiFiSocketClass::bound (SOCKET sock)
176
+ {
177
+ m2m_wifi_handle_events (NULL );
178
+
179
+ return (_info[sock].state == SOCKET_STATE_BOUND);
180
+ }
181
+
175
182
int WiFiSocketClass::available (SOCKET sock)
176
183
{
177
184
m2m_wifi_handle_events (NULL );
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ class WiFiSocketClass {
40
40
sint8 connect (SOCKET sock, struct sockaddr *pstrAddr, uint8 u8AddrLen);
41
41
uint8 connected (SOCKET sock);
42
42
uint8 listening (SOCKET sock);
43
+ uint8 bound (SOCKET sock);
43
44
int available (SOCKET sock);
44
45
int peek (SOCKET sock);
45
46
int read (SOCKET sock, uint8_t * buf, size_t size);
You can’t perform that action at this time.
0 commit comments