Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
This repository was archived by the owner on Jul 28, 2026. It is now read-only.

TCP sockets for connections #4

Description

@rakshith-ravi

Unix sockets will not work on windows. They only work on macOS and Linux.

Juno, however, supports standard inet sockets for communication. That needs to be incorporated into this library.

The following things are needed:

  • Similar to the rust library, JunoModule.ts should provide static functions called fromUnixSocket(path: string) and fromInetSocket(host: string, port: number).
  • The existing default(string) function should be modified to check if the string is a unix socket path or an inet socket and accordingly call the corresponding function.
  • The fromUnixSocket function should throw an error and crash the program when called on windows, with an appropriate error message.
  • There should be a src/connection/inet-socket-connection.ts file that implements the connection for inet sockets. You can take inspiration from unix socket to understand how it works.

Ping here if you need any help

Activity

  1. sauravhiremath commented on Apr 26, 2020

    @sauravhiremath
    Contributor

    Okay, i'll get started on it.

  2. sauravhiremath commented on Apr 27, 2020

    @sauravhiremath
    Contributor

    Could you specify why exactly are we using fromUnixSocket() and fromInetSocket() function?

    Instead,
    Specify InetSocketConnection() and UnixSocketConnection() in default() function by comparing the socketPath being unix_sock_path or named pipes (windows).

    Example snippet:

    public static default(socketPath: string): JunoModule {
    		if (['\\\\?\\pipe', '\\\\.\\pipe'].some(p => socketPath.includes(p))) {
    			return new JunoModule(new InetSocketConnection(socketPath), new JsonProtocol());
    		} else {
    			return new JunoModule(new UnixSocketConnection(socketPath), new JsonProtocol());
    		}
    	}

    Could the above snippet work?

  3. rakshith-ravi commented on Apr 28, 2020

    @rakshith-ravi
    MemberAuthor

    Could you specify why exactly are we using fromUnixSocket() and fromInetSocket() function?

    Those functions will allow you to explicitly set the connection type instead of depending on the default function to categorize it.

    Additionally, named pipes aren't supported by Juno....yet. I have no plans to support it as of now, since the throughput of named pipes are not the best. So, the default function should check if the string being passed is a unix socket (a file name) or a bind address. Based on that, it should call the fromUnixSocket or the fromInetSocket function.

    However, when the fromUnixSocket function is called from a windows system, it should error out.

  4. sauravhiremath commented on Apr 28, 2020

    @sauravhiremath
    Contributor

    Also, do I extract IP address from the string being passed if it has a valid domain name?

  5. rakshith-ravi commented on Apr 28, 2020

    @rakshith-ravi
    MemberAuthor

    There can't possibly be a domain name. That's an illegal string. The IP address that's mentioned there is the bind address (127.0.0.1 or 0.0.0.0 or any other bind address). Domain names aren't valid there

  6. added 2 commits that reference this issue on Apr 28, 2020
  7. added a commit that references this issue on May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions