Created
July 2, 2016 19:40
-
-
Save ayende/27b92bd5a9264593e469976ed348f6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Proxy() | |
{ | |
var tcpListener = new TcpListener(IPAddress.Loopback, 9000); | |
tcpListener.Start(); | |
var buffer = new byte[1024]; | |
while (true) | |
{ | |
var incomingConnection = tcpListener.AcceptTcpClient(); | |
var tcpClient = new TcpClient(); | |
tcpClient.Connect(IPAddress.Loopback, 9999); | |
using (var recv = incomingConnection.GetStream()) | |
using (var send = tcpClient.GetStream()) | |
{ | |
while (true) | |
{ | |
var read = recv.Read(buffer, 0, 1024); | |
if (read == 0) | |
break; | |
Thread.Sleep(1); | |
send.Write(buffer, 0, read); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment