I want to create a proxy server on sockets, ready-made solutions are unlikely to work because I already have a connection that is always open and which will receive raw requests like:
Yeah, like @notaghost made a good point: we sort of need to know what kind of thing you’re trying to build to give more feedback. I think that you want to build a TCP proxy to intercept traffic and debug it? If so, there are a number of premade SOCKS proxies that you can use:
Geniar (2017) discusses using SSH to create a SOCKS5 route to (mainly to bypass web filtering but can maybe be applied to your situation).
Wireshark (n.d.) is a “go to” utility for intercepting network traffic and can be used to capture traffic flowing through your NIC.
This one’s a bit old, but nixbit (n.d.) lists the infamous SPIKE Proxy which is used to fuzz network-based software through (obviously) a proxy.