Click here to Skip to main content
Licence 
First Posted 6 Sep 2005
Views 60,673
Bookmarked 59 times

EasySocket - Flexible and easy implementation of client-server architecture in C#

By | 23 Feb 2006 | Article
Using .NET Socket on TCP to create events oriented client-server behaviour.

Sample Image - EasySocketDocument.jpg

Introduction

My first encounter with Windows Sockets was about two months ago with MFC. At that time I simply wanted to experience some TCP\IP programming just before my next semester. That was the ugliest thing I've ever seen and I switched back to .NET. Although it was a lot easier I couldn't find objects that would give me client server behaviour right away and still will keep the flexibility of the Socket object (not to mention an event oriented one). So I took on myself a little project, 3-4 days I think. And I gave life to the EasySocket namespace and the EasyClient, and EasyServer classes.

EasyServer and EasyClient

EasyServer represents the server entity. It has very flexible and useful features. It's an event oriented object and sending any type of serializable object can be done in one line. Most of the methods have both synchronous and asynchronous versions (runs on separate threads). EasyServer was designed with EasyClient and they have a special functionality together (like communication testing), but with proper programming, it can also communicate with any client application. You can get information about the connected clients, their last transition time and more...

EasyClient is the client entity and was written with the same spirit of event oriented programming and can send\get data, make connection tests, connection status and more.

Usage Instructions

The downloadable source code has the EasySocket solution (*.sln file). Its output is a DLL file and an XML comments file. To use it in your own project, simply add to the project a reference to the EasySocket.dll file.

Documentation

I've spent a great deal of time commenting the code and generated detailed and easy to use documentation (HTML & WinHelp) and I recommend reading it in case you intend to change or understand the code. There are two types of documentation: one for client programmers (those who are using the DLL only), and second for programmers who want to edit the code (includes details about private members and private functions). Have fun...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

JadBenAutho

Software Developer
Rontal Applications
Israel Israel

Member

Born and raised in Israel, I've caught the programming virus at the age of 15.
Since than I can't stop coding.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralClient can't connect Server on the Internet Pinmemberlimdim23:59 24 Oct '07  
QuestionHow to know IP clients connected to EasyServer ? Pinmemberjopomo2:28 4 Oct '07  
AnswerRe: How to know IP clients connected to EasyServer ? PinmemberJadBenAutho0:39 5 Oct '07  
GeneralRe: How to know IP clients connected to EasyServer ? Pinmemberjopomo20:34 10 Oct '07  
QuestionDo you have an Easy Socket update for 2005? Pinmemberterryd16:35 27 Dec '06  
AnswerRe: Do you have an Easy Socket update for 2005? PinmemberJadBenAutho0:34 29 Dec '06  
GeneralMake Thread-Safe Calls to Windows Forms Controls PinmemberAkleinek6:38 2 Oct '06  
GeneralRe: Make Thread-Safe Calls to Windows Forms Controls PinmemberJadBenAutho0:23 3 Oct '06  
GeneralRe: Make Thread-Safe Calls to Windows Forms Controls PinmemberDrewcrewof27:55 8 Oct '06  
GeneralSome corrections Pinmemberflops4210:20 22 Feb '06  
GeneralRe: Some corrections PinmemberJadBenAutho21:29 22 Feb '06  
GeneralAbout UseSmartManagement PinmemberBruno Saboia de Albuquerque6:58 8 Dec '05  
GeneralRe: About UseSmartManagement PinmemberJadBenAutho20:39 8 Dec '05  
GeneralDemo Shutdown Problem Pinmemberlberman3:53 7 Sep '05  
GeneralRe: Demo Shutdown Problem PinmemberJadBenAutho8:50 7 Sep '05  
QuestionProblem running demo Pinmemberlberman11:03 6 Sep '05  
AnswerRe: Problem running demo PinmemberJadBenAutho20:06 6 Sep '05  
Hi lberman,
The TestServer and TestClient are simple example of using EasySocket namespace,
I can't tell you where is your prob' but here some IMPORTANT points:
 
//The same idea if you'r using your one solution:
1. Open the TestingServer solution, on line 14 in "form1.cs" file, see the construntor
of the server -> EasyServer S1 = new EasyServer(4000, "ShugonServ", true);
The port number here must be the same port number that you will set on the client
later. (try 4000, 2222 or any port that isn't in use).
 
go to line 208 : S1.SendData(TBOXout.Text, new ClientInfo("Master", true));
Change "Master" to the name or IP of the machine where the client is.
 
2. Open the TestingClient solution on line 13 in "form1.cs file":
EasyClient C1 = new EasyClient(new ServerInfo("Master",4000 ,true) );
see the constructor must get the port number that you put in the server,
and the IP of the machine(if it's on local network u CAN use the name of the machine,
if you simply dont know it give it the IP(on Command prompt write ipconfig to see
your IP). In your case this has to be the same string you wrote in the server
solution line 208 cos' it's the same machine.

3. Now be sure that the port you use is not blocked by a firewall. Run bouth solutions,
on the Client form click Is ready button (if the message box tells you that your
ready it's means you gave a legal IP or Machine name. On the server form
click "Listen", return to client form and click connect, if connection was made,
the status textbox should change to "Connected". That should work just fine,
if the prob' wasn't solved notice the excetion messages or and message at all
and tell me what dose it say, good luck.

 
Never put more than one leg at a time on the wall.
GeneralRe: Problem running demo Pinmemberlberman3:39 7 Sep '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 23 Feb 2006
Article Copyright 2005 by JadBenAutho
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid