الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

خطأ في برنامج مراقبة C# Client/server

بدأه aammrr في 9 ديسمبر 2008 · 0 رد · 387 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1

بســم الله الـرحمــن الرحيــم

كنت احاول عمل برنامج يلطقت صورة لشاشة الاجهزة الاخري

*جهاز مركزي يعمل ك client

*بقية الاجهزة تعمل ك servers

ولكن واجهة مشكلة حيث يصل الي مر حلة يتوقف الclient عن العمل

any way the client code

"

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Drawing.Imaging;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net;

using System.Net.Sockets;

using System.IO;

using System.Management;

namespace server_1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

IPAddress selected_ip;

selected_ip = IPAddress.Parse(TextBox1.Text.ToString()); //to select the ip

TcpClient _serverclinet = new TcpClient();

_serverclinet.Connect(selected_ip,45000);

NetworkStream _sc = _serverclinet.GetStream();

StreamWriter _scswriter = new StreamWriter(_sc);

_scswriter.WriteLine("s");

_scswriter.Flush();

pictureBox1.Image = Image.FromStream(_sc);

_serverclinet.Close();

}

}

}

"

the server code

"

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net;

using System.Net.Sockets;

using System.IO;

using System.Drawing.Imaging;

namespace Client_1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

//this is where the Clint work as a server to get the ok from the server

TcpListener _Clistener = new TcpListener(45000);

_Clistener.Start();

Socket _CSsocket = _Clistener.AcceptSocket();

NetworkStream _Cst = new NetworkStream(_CSsocket);

StreamReader _Csr = new StreamReader(_Cst);

string _ok = _Csr.ReadLine();

if (_ok == "s")

{

Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,PixelFormat.Format32bppArgb);

Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);// Create a graphics object from the bitmap

gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);// Take the screenshot from the upper left corner to the

MemoryStream _ms = new MemoryStream();

bmpScreenshot.Save(_ms,ImageFormat.Png);

byte[] _arrImage = _ms.GetBuffer();

_ms.Close();

BinaryWriter _mysw = new BinaryWriter(_Cst);

_mysw.Write(_arrImage);

_mysw.Flush();

_mysw.Close();

_Cst.Close();

};

}

}

}

شكرا علي الوقت والمجهود والصبر

مواضيع مشابهة