سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب کد ساخت Socket Connection در c#.net را آماده کردم. انشاالله که این کد سی شارپ براتون مفید باشد.
کد ساخت Socket Connection در c#.net :
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
class MainClass
{
[STAThread]
static void Main(string[] args)
{
TcpClient MyClient = new TcpClient();
MyClient.Connect("localhost", 10000);
NetworkStream MyNetStream = MyClient.GetStream();
if(MyNetStream.CanWrite && MyNetStream.CanRead)
{
Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there");
MyNetStream.Write(sendBytes, 0, sendBytes.Length);
byte[] bytes = new byte[MyClient.ReceiveBufferSize];
using System.Net;
using System.Net.Sockets;
using System.Text;
class MainClass
{
[STAThread]
static void Main(string[] args)
{
TcpClient MyClient = new TcpClient();
MyClient.Connect("localhost", 10000);
NetworkStream MyNetStream = MyClient.GetStream();
if(MyNetStream.CanWrite && MyNetStream.CanRead)
{
Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there");
MyNetStream.Write(sendBytes, 0, sendBytes.Length);
byte[] bytes = new byte[MyClient.ReceiveBufferSize];