考虑以下:
public void Connect()
{
clientObject = new TcpClient();
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 90);
centralForm.writeLog("Connecting to desired server", System.Drawing.Color.Gray, true);
clientObject.Connect(ipEnd);
if ((debug) && (clientObject.Connected)) { Debug.Print("Connected"); }
Send("0");
clientObject.GetStream().BeginRead(new byte[] { 0 }, 0, 0, Read, null);
}
我在这段代码的最后一行收到上述错误。我做错了什么?我已经调用了 Connect()... 我已经盯着这个看很久了,我真的不知道我做错了什么。
发送代码:
public void Send(string data)
{
using (StreamWriter w = new StreamWriter(clientObject.GetStream()))
{
w.WriteLine(data);
w.Flush();
}
}