www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23793] New: std.stdio.openNetwork should be refactored and

https://issues.dlang.org/show_bug.cgi?id=23793

          Issue ID: 23793
           Summary: std.stdio.openNetwork should be refactored and moved
                    to a different place
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: witold.baryluk+d gmail.com

std.stdio.openNetwork should be moved to different place

While I think it is useful in principle, it should not be in std.stdio.

It causes any program importing std.stdio, to link to network stack including
functions like gethostname, which with most libc will cause issues with static
linking.

It also slows down all the std.stdio imports for everybody, while maybe 0.001%
of people actually us that function.

A much better approach would be to have a function that accepts a TCP socket,
and converts it to std.stdio.File.

Such function should be in own module, like std.socket.file, or something like
this.

This way user is in a control of all connection settings, and function does
just one thing.

Right now openNetwork is too hermetic and does multiple things.

--
Mar 18 2023