cruny cruny - 1 year ago 121
C# Question

c# Pass Socket Connection

I have a List of sockets

List<Socket> Clients;

is receiving Data in a UI Form works perfectly , but i want to pass that socket to another Form2 so :

public Form2(Socket Client)

this._Client = Client;

in my Form1:

Form2 f2 = new Form2(this.Clients[0]);

My issue is i don't receive from the New socket i still receive from socket on Form1 !
i m confused how can i receive from the new socket !

Answer Source

There should only be one that will receive data from the socket. You should pass the data instead of the socket.

public class Form2 : Form
    public void HandleData(byte[] data)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download