Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0
Hello,
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.
Thnx
Regards,
Vishavdeep Goyal
Posted 14-Jun-11 23:23pm
Rate this: bad
good
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#[^]
  Permalink  
v2
Comments
SAKryukov at 15-Jun-11 19:22pm
   
Good option and a link, my 5;
see also my solution.
--SA
Kim Togo at 16-Jun-11 2:32am
   
Thanks SA
Rate this: bad
good
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.
 

—SA
  Permalink  
Comments
Kim Togo at 16-Jun-11 2:34am
   
Really good answer SA. My 5+
SAKryukov at 16-Jun-11 2:42am
   
Thank you, Kim.
--SA
Member_6499766 at 18-Jun-11 4:25am
   
nice one, my 4 :)
SAKryukov at 20-Jun-11 1:39am
   
Thank you. I understand, the answer could be better.
--SA
Rate this: bad
good
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[^]
  Permalink  
Comments
SAKryukov at 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.
--SA
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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[^]
  Permalink  
Comments
SAKryukov at 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.
--SA

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

  Print Answers RSS
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 15 Jun 2011
Copyright © CodeProject, 1999-2014
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