Click here to Skip to main content
13,089,386 members (63,250 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i am c# novice and am writing server send multiple clients. i am able to send to single client however not able to multiple clients.
server code

namespace server2
    public partial class server2 : Form
     List<tcpclient> _clients = new List<tcpclient>();
        public server2()
        private void server2_Load(object sender, EventArgs e)
           byte[] bt;
           bt = new byte[] { 127,0,0,1 };
           IPAddress address = new IPAddress(bt);
           byte[] bt;
           bt = new byte[] { 127,0,1,1 };
           IPAddress address = new IPAddress(bt);         

        private void send_Click(object sender, EventArgs e)
            foreach (TcpClient client in _clients)
                NetworkStream stream = client.GetStream();
                BinaryWriter bwrite = new BinaryWriter(stream);
        private void add_Click(object sender, EventArgs e)
            TcpClient client = new TcpClient();
            string ipAddress = txtClientAddress.Text;
            client.Connect(ipAddress, PORT);
            txtClientAddress.Text = "";

[edit]Code block added - OriginalGriff[/edit]
Posted 15-Feb-13 23:16pm
Updated 16-Feb-13 0:22am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try my article here : WCF Killer[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 16 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100