I'm building a small application that reads IRC chat messages. Everything is working fine both in release and debug as long as I run it from my IDE (Jetbrains Rider).
What I expect to happen and what happens when I run the program from my IDE is that _readStream.ReadLine(); should block the thread until a message comes in. For some reason when I run my app from the executable file the thread does not get blocked and the message "I should have been blocked" gets printed (look at code below). This happens for both release and debug executable file.
Why does this happen?
UPDATE:
IOException gives this message Can't read line, Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.
I Have tried to add it to exceptions in firewall and inbound and outbound rules, still no dice.
public void Connect()
{
_tcpClient.Connect(_ip, _port);
_readStream = new StreamReader(_tcpClient.GetStream());
_writeStream = new StreamWriter(_tcpClient.GetStream());
}
public string ReadMessage()
{
return _readStream.ReadLine();
}
protected void Run()
{
while (IsRunning())
{
try
{
string message = ReadMessage();
if (message == null)
{
Console.WriteLine("I should have been blocked");
}
}
catch (IOException ioException)
{
// ...
}
}
// ...
}