C# Socket Programming - Multiple Clients

Brian (Able Opus) · 366K views · 2013 · 29:08

Open on YouTube

Networking & internet infrastructureSoftware practice, open source & careerstutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a beginner-friendly walkthrough of C# client/server sockets, and many questions come from people who followed it and then got stuck extending it, such as broadcasting to all clients or connecting across machines.

Recommended by 3 people across 3 different months, 2013 to 2022.

What it is

A 29-minute 2013 screencast by Brian (Able Opus) that builds a C# TCP server and client using .NET sockets, with the server handling multiple connected clients through asynchronous callbacks. The description links to a tidier version of the code on GitHub and suggests Buffer.BlockCopy for faster copying.

What people said

Recommends DarkPh03n1X · 2014-07 · Stack Overflow · on “How to send data using tcpclient on button click event as many times as i want without reestablishing connection?”

I was asking myself this very question today , I came Across a YouTube video [this video] that explains it nicely. It should not be too hard to convert this code to a form application. The Main Trick Seems to be to multi-thread the incoming connections And Use asynchronous socket [LINK] rather than TcpListener(TcpListener may be easier how ever) I hope This Helps

Recommends Abdul · 2020-05 · Stack Overflow · on “Is there a any way to send values from Unity project to another program?”

Your question isn't specific and i'm not familiar with unity and c# but you should look into sockets. Normally in any language, you use sockets to communicate with other platforms. From a high level, you have a server and then clients can connect to that server and you can have a bidirectional communication flow where the client can send message to the server and the server can receive those messages and send stuff back or do an action. Here's a YouTube video of c# sockets -> [this video]

Recommends NGDeveloper · 2022-07 · Stack Overflow · on “I want to make an online App that send and recive data”

Nice goal. you have a lot to do, start with learning client/server applications - [this video] Then you need to build a database to hold all the questions and students. You can also make it more automatic by inserting the answers in advance and letting the software to grade the test without the need of the teacher to do so. It is a good goal for learning to develope! good luck!

Cites Simon Taylor · 2013-10 · Stack Overflow · on “C# Sockets and sending data to all clients”

OK, so I am not very good at programming in general, but I want to try my hand at using sockets. To start I watched a Youtube video which I followed step by step, I got the finished product working 100% to the guides however I wish to modify it in order for the server to be able to send a message to all connected clients. Here is the youtube video: [this video] So this is the code for the server class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Sockets; using System.Net; namespace Server { class Program { private static byte[] buffer = new byte[1024]; public static Socket _serverSocket = new Socket(AddressFa

Cites Romain Lambert · 2015-11 · Stack Overflow · on “Socket Programming c# / Client-Server communication”

I am trying to make 2 programs (in console application) in .NET that communicate together through the web (the code is from a video that you can find below, I am just trying to make the code work before adapting it). Forgive me, I'm not an experienced programmer. I have a server and a client, they work perfectly when I run both of them on my computer (locally). I can connect multiple clients to the server, send requests and get a response. I am facing the problem when i run the server on a computer and the client on an other one and I try to connect through the internet. I can connect to the server but communication does not work, there is no data exchange when try to request time as an exam

Cites Tyler Gregorcyk · 2016-04 · Stack Overflow · on “How to handle multiple TCP clients for communication”

Here is a example of a server that can handle multiple clients and respond to multiple clients class MultyClientServer { private static int bufferSize = 2048; private static byte[] buffer = new byte[bufferSize]; private static List<Socket> clientSockets = new List<Socket>(); private static Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); static void Main(string[] args) { Console.Title = "Server"; SetupServer(); Console.ReadKey(); CloseAllSockets(); } private static void SetupServer() { Console.WriteLine("Settings Up Server Plz Wait"); serverSocket.Bind(new IPEndPoint(IPAddress.Any, YOUR PORT HERE)); serverSocket.Listen(10); serverSocket.Begin

Cites Tyler Gregorcyk · 2016-04 · Stack Overflow · on “Clien-Server to run on different machines and multiple clients”

To allow the server and client to be on two different machines you need to change the clientSocket.Connect(new IPEndPoint(IPAddress.Loopback, PORT)); to IPAddress ipAd = IPAddress.Parse(YOUR IP HERE); clientSocket.Connect(ipAd, YOUR PORT HERE); Also ive made a simple client in my library if you want to check it out: [LINK] Now making a server that can handle multiple clients is a little harder but lucky for I've made a example class Server { private static int bufferSize = 2048; private static byte[] buffer = new byte[bufferSize]; private static List<Socket> clientSockets = new List<Socket>(); private static Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, Prot

Cites James · 2018-03 · Stack Overflow · on “C# Client-Server Sockets not connecting”

I typed in a C# client/server lesson from the following video tutorial,... C# Socket Programming - Multiple Clients [this video] I complied the program using Visual Studio 2017. The program complied without error and it works in a SINGLE computer. That is to say that if I run both the client and the server on the same computer they connect just fine. So everything appears to be working. However, when I try to put the client and server on different computers on my home network they won't connect. When asked by the security firewall I allow them both to have full access. I'm not understanding why they won't work when placed on different computers on the same home network connected via WiFi. The com

Cites Emir · 2018-09 · Stack Overflow · on “C# Issue sending message from Server to multiple Clients (Socket Programming)”

So I'm very interested in learning more sophisticated programming techniques and languages, and I've decided to further my study into C# by learning sockets and server programming. I stumbled upon a video [this video] that i bet a lot of you have already seen or heard of, and it's, in my opinion, pretty good at explaining most of what's going on. So my problem is specifically with essentially taking this code and making it a chat system that takes info from a client, sends it to the server, then from the server to ALL clients. I've looked up any tutorials and other stack overflow pages to no avail, at least to me. I can't seem to figure it out, and when someone has an answer they've simply writte

Cites Dzban Rudy · 2022-02 · Stack Overflow · on “How to get amount of clients and ping before joining the server?”

I'm creating a game which when you click multiplayer mode, there is supposed to be a list of servers (i can do this), but i'd like to list look like that: Server name Players online/max players Ping Server IP And for instance: Death match NO TANKS 15/40 40 ms 192.168.1.101:7390 I created server from this YouTube movie: [this video] Does anyone know how to get these informations (online players and ping) before joining the server?