derhuerst / derhuerst/node-sockopt
TypeError: getsockopt failed: Operation not supported (95)
- Dominant language
- JavaScript
- Stars
- 9
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I am starting a simple UDP listener and trying to adjust the receive buffer size, however even on reading the information, it seems to throw an error.
Code Snippet
```js
const dgram = require('dgram');
const {getsockopt, setsockopt} = require('sockopt')
const SO_RCVBUF = 0x1002
const SOL_SOCKET = 0xffff
function startUDPServer (port = 9060, address = defaultBindIP) {
const socket = dgram.createSocket('udp4')
socket.on('error', (err) => log('UDP Error', err.message))
socket.on('listening', () => {
log('UDP Started', socket.address().address, socket.address().port)
console.log('SO_RCVBUF is', getsockopt(socket, SOL_SOCKET, SO_RCVBUF));
setsockopt(socket, SOL_SOCKET, SO_RCVBUF, 1024); // 1MB
console.log('SO_RCVBUF is now', getsockopt(socket, SOL_SOCKET, SO_RCVBUF));
})
socket.on('close', () => log('UDP Socket Closed', socket.address().address, socket.address().port))
socket.on('message', (msg, socket) => {
udpMsg++;
processMessage(msg, socket);
})
socket.bind(port, address)
}
```
This works fine without the `getsockopt` bits used.
Which causes the following error:
```
node_modules/sockopt/index.js:17
return _getsockopt(fd(socket), level, flagName)
^
TypeError: getsockopt failed: Operation not supported (95)
at getsockopt (/var/apps/hep-connexcs/node_modules/sockopt/index.js:17:9)
at Socket. (/var/apps/hep-connexcs/modules/ingress.js:32:32)
at Socket.emit (events.js:400:28)
at startListening (dgram.js:172:10)
at dgram.js:364:7
at processTicksAndRejections (internal/process/task_queues.js:83:21)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the supplied UDP listener, then inspect node_modules/sockopt/index.js at line 17 and the call from modules/ingress.js:32. Compare the socket type and option arguments used by dgram with the behavior that returns Operation not supported (95). Done means the cause is verified and the supported behavior or required correction is clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100