1
Does anyone know what the problem is with this code below? The following error is occurring: "The stream is not writable"
TcpListener tcpl = new TcpListener(500);
tcpl.Start();
Socket sock = tcpl.AcceptSocket();
NetworkStream stream = new NetworkStream(sock);
BinaryWriter write;
while (true)
{
string Resp = string.Format("{0}\n{1}\n{2}",
"HTTP/1.1 890 FOUND",
"",
"<h1>Worked!</h1>"
);
write = new BinaryWriter(stream);
write.Write(Resp);
write.Close();
}
tcpl.Stop();
sock.Close();
stream.Close();
When does it come out of the loop? And for what that loop?
– Andre Figueiredo
The "never" loop exits, it is a "server" that receives connections continuously. It serves precisely to never stop receiving and answering connections.
– Nickolas Carlos
ok.. but in that case use
socket.Connected
to verify.– Andre Figueiredo