Skip to content

Commit cfe4f64

Browse files
gdsportsfpistm
authored andcommitted
Allocate the TCP client when needed.
This patch allows the WebClientRepeating example to work.
1 parent 75fefe6 commit cfe4f64

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/EthernetClient.cpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,13 @@ int EthernetClient::connect(const char* host, uint16_t port) {
4040
}
4141

4242
int EthernetClient::connect(IPAddress ip, uint16_t port) {
43-
/* Can't create twice the same client */
44-
if(_tcp_client != NULL) {
45-
return 0;
46-
}
47-
48-
/* Allocates memory for client */
49-
_tcp_client = (struct tcp_struct *)mem_malloc(sizeof(struct tcp_struct));
50-
5143
if(_tcp_client == NULL) {
52-
return 0;
44+
/* Allocates memory for client */
45+
_tcp_client = (struct tcp_struct *)mem_malloc(sizeof(struct tcp_struct));
46+
47+
if(_tcp_client == NULL) {
48+
return 0;
49+
}
5350
}
5451

5552
/* Creates a new TCP protocol control block */

0 commit comments

Comments
 (0)