Click here to Skip to main content
11,921,479 members (63,987 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0
I have to establish a connection between server and client.Only one server and so many clients.I have to make a windows application in c sharp.can u plz. give me the idea about this.
Vishavdeep Goyal
Posted 14-Jun-11 23:23pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Use TcpClient Class[^] on the client side and TcpListener Class[^] on the server side.

There is a good beginner example on how to get started.

An Introduction to Socket Programming in .NET using C#[^]
SAKryukov 15-Jun-11 19:22pm
Good option and a link, my 5;
see also my solution.
Kim Togo 16-Jun-11 2:32am
Thanks SA
Rate this: bad
Please Sign up or sign in to vote.

Solution 5

There are several levels of networking you can use.
Here is what you can consider:

Low sockets level using System.Net.Sockets.Socket, a little higher socket levels using System.Net.Sockets.UdpClient (UDP), System.Net.Sockets.TcpListener/System.Net.Sockets.TcpClient (TCP), .NET remoting, WCF (self-hosted or not).

Lower levels will need Marshaling and/or Serialization; you may also need to know how to create and use DataContract and/or ServiceContract, especially with WCF. One of the most essential aspects will be threading and thread synchronization.

I would suggest you don't try to communicate between applications (it depends on your goal though). It's usually more productive to think in terms of service (not necessarily client-server) and clients.

Making even most elementary examples on every level would make a really big article, may be… hard to estimate… some tens of pages. Who will write it for you? Better try to find articles of separate topic in CodeProject and create prototype applications using each technique. Only in this way you will be able to feel them well enough to decide on designs on your applications.

Basic advice: don't try to send UI controls and the like, like some do. Create pure-data types and send pure data; create loose coupling between data and UI, isolate UI from data model, universal functionality and application-specific functionality.

Kim Togo 16-Jun-11 2:34am
Really good answer SA. My 5+
SAKryukov 16-Jun-11 2:42am
Thank you, Kim.
Member_6499766 18-Jun-11 4:25am
nice one, my 4 :)
SAKryukov 20-Jun-11 1:39am
Thank you. I understand, the answer could be better.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

This is not a new problem: A quick google using your subject line as the search term gave nearly 400 million hits, most of which explain how to do it. Google[^]
SAKryukov 15-Jun-11 19:23pm
A vote of 1 countered by my 5. The real reason is that I agree with this soluton, of course.
See also my solution.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

You need to pick up a book or look at some online sampls and start reading.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

yes OriginalGriff is right. you should search it on the google first. you will get billion result for that, and also you will get the answer from the google...
But it depend on how you search it on google[^]
SAKryukov 15-Jun-11 19:24pm
Not the best search string, I would say...
I provided an answer where the search key work could be found at least.
Please see.

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

  Print Answers RSS
0 OriginalGriff 553
1 Dave Kreskowiak 245
2 phil.o 160
3 KrunalRohit 134
4 Sergey Alexandrovich Kryukov 132
0 OriginalGriff 6,951
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,171
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web01 | 2.8.151120.1 | Last Updated 15 Jun 2011
Copyright © CodeProject, 1999-2015
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