1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-11 15:22:13 +03:00

Fix UDP send to not temporarily use connect()

This commit is contained in:
Jon Watte
2015-05-10 14:00:50 -07:00
parent 5407b064b0
commit 3049d48d56
3 changed files with 9 additions and 7 deletions

View File

@ -132,14 +132,13 @@ int WiFiUDP::beginPacket(const char *host, uint16_t port)
int WiFiUDP::beginPacket(IPAddress ip, uint16_t port)
{
ip_addr_t addr;
addr.addr = ip;
if (!_ctx) {
_ctx = new UdpContext;
_ctx->ref();
}
return (_ctx->connect(addr, port)) ? 1 : 0;
begunIp_ = ip;
begunPort_= port;
return 1;
}
int WiFiUDP::beginPacketMulticast(IPAddress multicastAddress, uint16_t port,
@ -167,8 +166,9 @@ int WiFiUDP::endPacket()
if (!_ctx)
return 0;
_ctx->send();
_ctx->disconnect();
ip_addr_t addr;
addr.addr = begunIp_;
_ctx->send(&addr, begunPort_);
return 1;
}