0% found this document useful (0 votes)
6 views1 page

TCP Client

This C# program is a simple TCP client that connects to a server using a specified IP address and port 1308. It continuously prompts the user for text input, sends the input to the server, and displays the server's response. The program uses a stream writer and reader to handle communication over the TCP connection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

TCP Client

This C# program is a simple TCP client that connects to a server using a specified IP address and port 1308. It continuously prompts the user for text input, sends the input to the server, and displays the server's response. The program uses a stream writer and reader to handle communication over the TCP connection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace Client
{
internal class Program
{
private static void Main()
{
Console.Write("Server Ip: ");
var ip = IPAddress.Parse(Console.ReadLine());
while (true)
{
Console.Write("# Text >>> ");
var text = Console.ReadLine();
var client = new TcpClient();
client.Connect(ip, 1308);
var stream = client.GetStream();
var writer = new StreamWriter(stream) { AutoFlush = true
};
var reader = new StreamReader(stream);
writer.WriteLine(text);
var response = reader.ReadLine();
client.Close();
Console.WriteLine(response);
}
}
}
}

You might also like