rendered paste bodyusing System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
namespace IrcLib
{
public class IrcConnection
{
private bool m_connected;
private StreamReader m_read;
private StreamWriter m_write;
public bool Connected
{
get { return m_connected; }
}
public void Connect(string adress, int port)
{
TcpClient m_client = new TcpClient();
try
{
m_client.Connect(adress, port);
m_connected = true;
}
catch (Exception)
{
m_connected = false;
}
m_read = new StreamReader(m_client.GetStream());
m_write = new StreamWriter(m_client.GetStream());
}
public string ReadLine()
{
string lineRead = string.Empty;
try
{
lineRead = m_read.ReadLine();
}
catch (Exception)
{
m_connected = false;
return "!DISCONNECTED!";
}
return lineRead;
}
public void WriteLine(string line)
{
try
{
m_write.WriteLine(line);
m_write.Flush();
}
catch (Exception)
{
m_connected = false;
}
}
}
}