-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
How to use fd with net.Socket? #8297
Comments
What exactly are you trying to do? If you want to connect to a remote host over TCP, hy do you want to create the file descriptor explicitly instead of letting node.js / libuv handle that for you? |
Does that mean a valid TCP pipe is only being created by I had to add |
'TCP pipe' is a bit of an oxymoron - TCP sockets and pipes are different things. The
I'm not aware of any such changes, I don't think the logic around |
How to do so in the code? Let's say I want to create and reuse such a socket/pipe. |
Put it in man pages terms, if only the public I guess at the moment there is no way to get a fd of a fresh unbound socket purely with the existing public |
This code will cause problems with an error:
Randomly, depending on how stdout and stderr are repiped of the process, it will give this error:
TypeError: Unsupported fd type: FILE
What the heck does that mean? Everything on stackoverflow is 100% unrelated where people try to create sockets to files. Here I want to create a Socket to a TCP remote port (client-side socket implementation), but the pipe itself is later created using
connector.connect({host: host, port: port})
.So at the constructor point in time there can't be such a thing as an already existing TCP Pipe(!?!?!?!).
Debugging
I figured out that the
TCP
type file descriptor is necessary lib/net.js#L31.The
tty_wrap.guessHandleType(fd)
uses internal representations to return type TCP tty_wrap.cc#L66.Solution?
How to solve this and create a file descriptor for net.Socket?
Having a FILE fd does not help obviously, but there is literally zero documentation on how to create a file descriptor for TCP. I tried to read all the TCP relevant code, but UV_TCP is pretty much everywhere in code related to streams, files, handles and uv ... seems as this is a if/else construct in the whole codebase.
OS Information
Debian, Ubuntu, Archlinux. All amd64 and verified the identical problem.
The text was updated successfully, but these errors were encountered: