The ideal connection implementation for an internet cafe software - c#

I am coding an internet cafe program and trying to decide which path to take. I've read some articles and came to know that there are a few ways to implement a server/client connection.(a bit messy Asyncronous, simple TCP and Socket) I'm a bit confused. I kindly ask you to show me the ideal way regarding to the needs that I mentioned below
Clients will always stay connected to server and server will know when any client is disconnected. Server will send object and string to clients, clients will send string to server.
So, Should I use an asyncronous or simple tcp or what? Thanks in advance

Have you looked at WCF?

There are quite a few good tutorials out there to help you get started on this.
It sounds like you have the basic functionality in mind, so take a look at this tutorial - hopefully it can help you out.
http://www.codeproject.com/KB/IP/tcpclientserver.aspx

Also you can look this site for basic requirements
http://www.java2s.com/Code/CSharp/Network/CatalogNetwork.htm

Related

How to communicate between two C# applications(sending messages and receiving messages)?

As per my knowledge, I knew that messages can posted from one application to other application using "SendMessage" or "PostMessage".
I tried using SignalR to communicate b/w the applications. The problem here i found was server should be launched as a console application and clients will be my winforms. Ideally I don't want to show this console application as it seems to be weird for the user. If there is any work around for this approach please suggest.
After signalR I came across EventAggregrator in c#. Can we use EventAggregrator to communicate b/w two different C# applications? If yes could some one give an example on how to do this.
Until a few years ago, Socket class was the right way to do this. There are probably more modern, robust and easier ways to achieve the same result nowadays, but you may want to look at what's under the hood.
Socket class on MSDN:
https://msdn.microsoft.com/it-it/library/system.net.sockets.socket%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
Client-server example on CodeProject:
https://www.codeproject.com/articles/463947/working-with-sockets-in-csharp

Throttling network for other applications

A friend likes to limit his applications to a use a certain bandwidth-limit. Seen as he doesn't have the widest connection and - for example - not every application that downloads/uploads has the ability to throttle/limit their downloads/uploads (Like Steam or a torrent downloader.). So he was wondering if I could maybe put something together since I fiddle around with WinForms often. I recommended NetLimiter and NetBalancer, but I was curious as to whether I could make this in C# myself.
I have searched the web and found some decent solutions as to throttling in an application itself but as to throttling applications outside of the current application you have the source code of, I haven't been able to find anything that would help me understand how to program this from scratch.
Do any of you know how I'd go about throttling other applications? Would I have to write my own network interface and have Windows reroute traffic through that?
Thank you for your time.
EDIT: Seen as the first comment tells me I'm at the wrong address with C#, I rephrased my question in the hopes of a better way to get an answer.

how to display speed of internet connection in web application?

I have a asp.net web application that uses C#. It logs in on a remote machine and download files from the server. I wish to display bandwidth available during the connection or the speed of connection.
What could be the best possible way if I m not allowed to use any external library or APIs? How can I implemet it using Javascript?
Thanks in advance. :)
Have a look at the following page:
Determining available bandwidth
It suggests there isnt really an easy way of doing it.
This one has some ideas of how to do it though:
Detecting network connection speed and bandwidth usage in C#
Hope they help.
This article does a good job of explaining how Google Analytics calculates speed.
As suggested by the article one of the easiest to implement but least accurate ways could be to implement / build a solution that matches the users IP address against the ISP that IP address belongs to, then "assume" the connection speed. I personally feel this would be way too inaccurate but it might be enough for your needs, especially if you are working on an application running over a closed WAN.

any WCF libraries to make it simple?

I've got I admit that I'm probably too dumb to fully learn and understand WCF. :(
On the other hand I had learned and used xmpp pretty well ( using MatriX XMPP library ).
So I wanted to ask, maybe there are some other libraries that help passing data from one computer to another to make life simple?
i.e. a library that would open a port/connection and both listen to incoming commands from other computers, as well as be able to send such commands to other computers that are listening to it.
Thanks!
WCF is not a hard technology... there is a learning curve, but ultimately someone who has taken the time to learn how to do it can easily implement the functionality in a couple of minutes.
i.e. a library that would open a
port/connection and both listen to
incoming commands from other
computers, as well as be able to send
such commands to other computers that
are listening to it.
Not really. Most of WCF involves setting up your app.config files so that they work on both ends. And I doubt there are any libraries that can do that for you.
You simply HAVE to generate and implement a service contract and implement the endpoints/meta data.
MSDN actually has a very decent tutorial. Getting Started Tutorial
Even if you DID find a "helper" you should still take the time to learn the technology so that you are prepared to troubleshoot and fix it when it breaks.
And if:
I've got I admit that I'm probably too
dumb to fully learn and understand
WCF. :(
were true... you wouldn't be a programmer.
My journey to understanding WCF happened right here on Stackoverflow... you can check it out at : Cross Application Communication (C#).
It might help you understand a little bit better.
Two options come to mind.
If you want to use WCF, the check out ECollective from SOA Collective. Uses managed mode Discovery to create a config-free WCF client, abstracting all of the things that makes WCF hard like bindings and behaviors.
If you want to use something other than WCF, check out NServiceBus.
Try the Idesign Website ... they have a WCF library that you can download and use in your projects.

Communication between C# applications - the easy way

I have two C# programs and I want to send some data back and forth between them. (And check if the data arrived to the other application.)
The two programs will always run on the same computer, so no networking capability is required. I've already read some questions with similar topics here, but I'm not entirely sure which is the right method for me. (WCF, Remoting, etc.)
What I want to know, is which one is the easier to implement for a beginner in C#?
(I don't want it to get too complicated anyway, it's only a few integers and some text that I want to send.)
If there isn't a real difference in difficulty, what advantages does one have over the other?
I'd really appreciate some simple example code as well.
Thanks in advance.
You can use Pipes to send data between different instances of your application. If you just need to tell the other instance that something has happened you can send messages from one application to another by using SendMessage api.
WCF essentially packages up the various methods of communication between applications (web services, remoting, MSMQ etc) in a single package, so that they are programmatically the same in the way that they are used, and the detail of what method is used is left for configuration of the binding between. A slight simplification perhaps, but essentially what it's about.
It is worth getting into WCF if you need inter-process communication, and this would certainly be my advice as to the way to go with this. It's worth looking at IDesign, who produce a number of articles on the subject, as well as some reusable code libraries, that you may find useful. Their Juval Lowy has also written an excellent book on the subject,
Another good point about WCF is that if your requirements ever change and all of a sudden you have to move one of the application to a different machine, requiring now network capability, you will only need to change configuration on both sides, instead of having to recode.
Plus, ad David said, WCF is a good tool to have in your bag.
Cheers, Wagner.
I found MSMQ is simple to implement.

Categories

Resources