I tried to resolve the problem using the references in the comment, but with no result. So here is the original code.
server
IPAddress ipAddress = IPAddress.Any;
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
TcpListener Listener = new TcpListener(localEndPoint);
Listener.Start();
Console.WriteLine("Waiting for a connection...");
TcpClient tcpClient = Listener.AcceptTcpClient();
NetworkStream stream = tcpClient.GetStream();
XDocument xmlNewInit = XDocument.Load(stream);
// Send back a response.
byte[] msg = Encoding.ASCII.GetBytes("Object created!");
stream.Write(msg, 0, msg.Length);
client
IPAddress ipAddress = IPAddress.Parse("192.168.1.49");
IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
// Create a TCP/IP socket.
TcpClient tcpClient = new TcpClient();
// Connect the socket to the remote endpoint. Catch any errors.
tcpClient.Connect(remoteEP);
textBox.Text = "Socket connected to " + remoteEP.ToString();
NetworkStream stream = tcpClient.GetStream();
XElement NewInit = new XElement(.....)
NewInit.Save(stream);
// Receive the response from the remote device.
int bytesRec = stream.Read(bytes, 0, bytes.Length);
textBox.Text = Encoding.ASCII.GetString(bytes, 0, bytesRec);