title: C# Sockets Receive Method Does not Receive Data
body: <p>I am having an odd problem and need someone's help.  I have a program that acts as part of a proxy chain.  It takes in data from one thing and sends it to another.  The only problem I am having is that the receive method takes in nothing.  It just freezes there.  My program:</p>
  
  <p>Let's say we have four nodes in the chain: A, B, C, and D.</p>
  
  <p>A is a web browser</p>
  
  <p>B is my C# program</p>
  
  <p>C is my C# client</p>
  
  <p>D is a website</p>
  
  <p>B is listening for <em>both</em> C and A.  Very weird, I know, but that's how I need it configured.  How can I get this damn program to work?  I already have a good amount of code set up, but for some reason, C is not receiving anything from B.  C connects to B all right, but C will not receive anything.  Can anyone help me?</p>
  
  <p>I have all of my ports opened, my firewall is off for both B and C.  A and B are both running on my local machine.  To give you some IPs:</p>
  
  <p>A connects to 127.0.0.1:3056</p>
  
  <p>B listens for 127.0.0.1:3056 and B listens for IPAddress.Any:3055</p>
  
  <p>C connects to MY_IP_ADDRESS:3055 and C connects to wherever B tells it</p>
  
  <p>where MY_IP_ADDRESS is my global IP address taken from whatismyip.com</p>
  
  <p>Why isn't C receiving anything?  Here is some surrounding code:</p>
  
  <p>Client (C):</p>
  
  <pre><code>Socket reqSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  IPEndPoint ip = new IPEndPoint(IPAddress.Parse("MY_IP_ADDRESS"), 3055);
  reqSocket.Connect(ip);
  byte[] ReqData = new byte[8192];
  MessageBox.Show("BYTE"); // This runs, (click OK)
  reqSocket.Receive(ReqData);
  String ReqString = Encoding.UTF8.GetString(ReqData);
  MessageBox.Show(ReqString); // This does not
  </code></pre>
  
  <p>Server (B):</p>
  
  <pre><code>TcpListener listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 3056);
  listener.Start();
  Socket Localhost = listener.AcceptSocket();
  listener.Stop();
  TcpListener listener2 = new TcpListener(IPAddress.Any, 3055);
  listener2.Start(50);
  Socket toSocket = listener2.AcceptSocket();
  listener2.Stop();
  byte[] buf = new byte[8192];
  Localhost.Receive(buf);
  toSocket.Send(buf);
  MessageBox.Show("Sent!"); // This runs
  </code></pre>
  
  <p>These are both indeed open at the same time.</p>