Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C# Reading paints to flowLayoutPanel using C# Sockets from server side

danielsalama

New Coder
I am trying to make an live paint program, what means that the server side will draw something and the client side will get it.


I worked very hard on it for two weeks, and I was only able to make a server side that sends the drawings. I do not know how I can get them from a client side and have them appear on his screen.

here is my server side code that works:

Code:
private void flowLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
            {
                if(pen_moving && pen_moving && pen_x != -1 && pen_y != -1)
                {

                    location = e.Location;

                    draw.DrawLine(my_pen, new Point(pen_x, pen_y), e.Location);

                    networkStream = client.GetStream();

                    StreamWriter swr = new StreamWriter(networkStream);
                    swr.WriteLine(location);
                
                    BinaryFormatter binFormatter = new BinaryFormatter();
                    binFormatter.Serialize(networkStream, sendingdraws());


                }

            }

            private Point sendingdraws()
            {
                Point toSend = new Point(pen_x, pen_y);
                draw.DrawLine(my_pen, new Point(pen_x, pen_y), location);
                return toSend;

            }

I think I need to convert on the client side the bytes that the server side sends to Point, and I also need to convert the location to Point. And then I can print them on the screen of the client side and there will be a drawing, but I do not know how to do it even after very hard work and a lot of effort. Therefore, I would be very happy if you could help me.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom