using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
public class AsynchNetworkClient
{
public static Main()
{
TcpClient tcpSocket = new TcpClient("127.0.0.1", 65000);
NetworkStream streamToServer = tcpSocket.GetStream();
System.IO.StreamWriter writer =new System.IO.StreamWriter(streamToServer);
writer.WriteLine("Hello Programming C#");
writer.Flush();
System.IO.StreamReader reader =new System.IO.StreamReader(streamToServer);
string strResponse = reader.ReadLine();
Console.WriteLine("Received: {0}", strResponse);
streamToServer.Close();
}
}
|