Skip to content

Add TCP message peeking #50

Description

@mahmed2000

I would like a way to be able to peek data from a tcp connection, without actually taking it from the socket output, so I can read it later. For example, peeking the TLS ClientHello to inspect the SNI hostname and then either upgrading the connection via ssl.handshake, or tunneling the encoded TCP stream with the ClientHello somewhere else.

Erlang's gen_tcp does not allow setting socket flags like MSG_PEEK on recv calls to do this.

However, according to this old issue and the gen_tcp source:

-export([send/2, recv/2, recv/3, unrecv/2]).

There exists a function gen_tcp:unrecv that does this in a hacky way. Could this be added to glisten/tcp, barring any plans to switch to the newer socket module?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions