Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno node compatibility issue where the callback object in net.createServer is missing fd #27788

Open
muthu90tech opened this issue Jan 23, 2025 · 0 comments · May be fixed by #27789
Open

Deno node compatibility issue where the callback object in net.createServer is missing fd #27788

muthu90tech opened this issue Jan 23, 2025 · 0 comments · May be fixed by #27789

Comments

@muthu90tech
Copy link
Contributor

In Node the following code will print the file descriptor, but in Deno the socket._handle.fd will be undefined, I noticed there is a gap in compatibility , I would like to address this sending small PRs to close the Socket fd compatibility gap.

import {createServer} from "node:net"

// Create a TCP server
const server = createServer((socket) => {
  console.log('Client connected');

  // Access the file descriptor of the socket
  const fd = socket._handle.fd;
  console.log('Socket file descriptor:', fd);

  socket.on('data', (data) => {
    console.log('Received data:', data.toString());
  });

  socket.on('end', () => {
    console.log('Client disconnected');
  });


});

// Bind the server to a port
server.listen(8080, '0.0.0.0', () => {
  console.log('Server listening on port 8080');
});

Version:
deno 2.1.7 (stable, debug, x86_64-unknown-linux-gnu)
v8 13.0.245.12-rusty
typescript 5.6.2

muthu90tech added a commit to muthu90tech/deno that referenced this issue Jan 23, 2025
…back socket object

This PR will address the node compatibility issue where, the callback socket
object in net.createServer is missing a fd in socket._handle

fixes: denoland#27788
muthu90tech added a commit to muthu90tech/deno that referenced this issue Jan 23, 2025
…lback socket object

This PR will address the node compatibility issue where, the callback socket
object in net.createServer is missing a fd in socket._handle

fixes: denoland#27788
muthu90tech added a commit to muthu90tech/deno that referenced this issue Jan 23, 2025
…lback socket object

This PR will address the node compatibility issue where, the callback socket
object in net.createServer is missing a fd in socket._handle

fixes: denoland#27788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant