Skip to content

Commit da0382a

Browse files
committed
handle udp send errors
fixes webtorrent#71 "Port should be > 0 and < 65536"
1 parent 1ec4eaa commit da0382a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ Server.prototype.onUdpRequest = function (msg, rinfo) {
219219
response.connectionId = params.connectionId
220220

221221
var buf = makeUdpPacket(response)
222-
self.udp.send(buf, 0, buf.length, rinfo.port, rinfo.address)
222+
223+
try {
224+
self.udp.send(buf, 0, buf.length, rinfo.port, rinfo.address)
225+
} catch (err) {
226+
self.emit('warning', err)
227+
}
223228

224229
if (params.action === common.ACTIONS.ANNOUNCE) {
225230
self.emit(common.EVENT_NAMES[params.event], params.addr)

0 commit comments

Comments
 (0)