Click here to Skip to main content
15,881,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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#[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 15-Jun-11 19:22pm    
Good option and a link, my 5;
see also my solution.
--SA
Kim Togo 16-Jun-11 2:32am    
Thanks SA
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
 
Share this answer
 
Comments
Kim Togo 16-Jun-11 2:34am    
Really good answer SA. My 5+
Sergey Alexandrovich Kryukov 16-Jun-11 2:42am    
Thank you, Kim.
--SA
parmar_punit 18-Jun-11 4:25am    
nice one, my 4 :)
Sergey Alexandrovich Kryukov 20-Jun-11 1:39am    
Thank you. I understand, the answer could be better.
--SA
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[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 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
You need to pick up a book or look at some online sampls and start reading.
 
Share this answer
 
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[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900