Skip to content
This repository was archived by the owner on Apr 23, 2023. It is now read-only.

Commit ac892f1

Browse files
committed
Fixed socket
1 parent 6df883d commit ac892f1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

cpp_utils/Socket.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Socket Socket::accept() {
6060
ESP_LOGD(LOG_TAG, ">> accept: Accepting on %s; sockFd: %d, using SSL: %d", addressToString(&addr).c_str(), m_sock, getSSL());
6161
struct sockaddr_in client_addr;
6262
socklen_t sin_size;
63-
int clientSockFD = ::lwip_accept_r(m_sock, (struct sockaddr*) &client_addr, &sin_size);
63+
int clientSockFD = ::lwip_accept(m_sock, (struct sockaddr*) &client_addr, &sin_size);
6464
//printf("------> new connection client %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
6565
if (clientSockFD == -1) {
6666
SocketException se(errno);
@@ -117,7 +117,7 @@ int Socket::bind(uint16_t port, uint32_t address) {
117117
serverAddress.sin_family = AF_INET;
118118
serverAddress.sin_addr.s_addr = htonl(address);
119119
serverAddress.sin_port = htons(port);
120-
int rc = ::lwip_bind_r(m_sock, (struct sockaddr*) &serverAddress, sizeof(serverAddress));
120+
int rc = ::lwip_bind(m_sock, (struct sockaddr*) &serverAddress, sizeof(serverAddress));
121121
if (rc != 0) {
122122
ESP_LOGE(LOG_TAG, "<< bind: bind[socket=%d]: %d: %s", m_sock, errno, strerror(errno));
123123
return rc;
@@ -144,7 +144,7 @@ int Socket::close() {
144144
rc = 0;
145145
if (m_sock != -1) {
146146
ESP_LOGD(LOG_TAG, "Calling lwip_close on %d", m_sock);
147-
rc = ::lwip_close_r(m_sock);
147+
rc = ::lwip_close(m_sock);
148148
if (rc != 0) {
149149
ESP_LOGE(LOG_TAG, "Error with lwip_close: %d", rc);
150150
}
@@ -170,7 +170,7 @@ int Socket::connect(struct in_addr address, uint16_t port) {
170170
inet_ntop(AF_INET, &address, msg, sizeof(msg));
171171
ESP_LOGD(LOG_TAG, "Connecting to %s:[%d]", msg, port);
172172
createSocket();
173-
int rc = ::lwip_connect_r(m_sock, (struct sockaddr*) &serverAddress, sizeof(struct sockaddr_in));
173+
int rc = ::lwip_connect(m_sock, (struct sockaddr*) &serverAddress, sizeof(struct sockaddr_in));
174174
if (rc == -1) {
175175
ESP_LOGE(LOG_TAG, "connect_cpp: Error: %s", strerror(errno));
176176
close();
@@ -268,7 +268,7 @@ int Socket::listen(uint16_t port, bool isDatagram, bool reuseAddress) {
268268
// For a datagram socket, we don't execute a listen call. That is is only for connection oriented
269269
// sockets.
270270
if (!isDatagram) {
271-
rc = ::lwip_listen_r(m_sock, 5);
271+
rc = ::lwip_listen(m_sock, 5);
272272
if (rc == -1) {
273273
ESP_LOGE(LOG_TAG, "<< listen: %s", strerror(errno));
274274
return rc;
@@ -356,7 +356,7 @@ size_t Socket::receive(uint8_t* data, size_t length, bool exact) {
356356
ESP_LOGD(LOG_TAG, "rc=%d, MBEDTLS_ERR_SSL_WANT_READ=%d", rc, MBEDTLS_ERR_SSL_WANT_READ);
357357
} while (rc == MBEDTLS_ERR_SSL_WANT_WRITE || rc == MBEDTLS_ERR_SSL_WANT_READ);
358358
} else {
359-
rc = ::lwip_recv_r(m_sock, data, length, 0);
359+
rc = ::lwip_recv(m_sock, data, length, 0);
360360
if (rc == -1) {
361361
ESP_LOGE(LOG_TAG, "receive: %s", strerror(errno));
362362
}
@@ -374,7 +374,7 @@ size_t Socket::receive(uint8_t* data, size_t length, bool exact) {
374374
rc = mbedtls_ssl_read(&m_sslContext, data, amountToRead);
375375
} while (rc == MBEDTLS_ERR_SSL_WANT_WRITE || rc == MBEDTLS_ERR_SSL_WANT_READ);
376376
} else {
377-
rc = ::lwip_recv_r(m_sock, data, amountToRead, 0);
377+
rc = ::lwip_recv(m_sock, data, amountToRead, 0);
378378
}
379379
if (rc == -1) {
380380
ESP_LOGE(LOG_TAG, "receive: %s", strerror(errno));
@@ -432,7 +432,7 @@ int Socket::send(const uint8_t* data, size_t length) const {
432432
}
433433
}
434434
} else {
435-
rc = ::lwip_send_r(m_sock, data, length, 0);
435+
rc = ::lwip_sendto(m_sock, data, length, 0);
436436
if ((rc < 0) && (errno != EAGAIN)) {
437437
// no cure for errors other than EAGAIN - log and exit
438438
ESP_LOGE(LOG_TAG, "send: socket=%d, %s", m_sock, strerror(errno));

0 commit comments

Comments
 (0)