I'm building a server-client application that uses TCP/IP sockets to communicate and i want to build a web interface to manage things.
Technologies:
-TCP/IP Sockets;
-Entity Framework 6 Code First;
My solution consists of four projects:
1) Server (Console application, runs 24/7, recieves data and writes to the db);
2) Client (Console application, runs 24/7 sends data);
3) NetLib (Class Library);
4) Interface (WebForms, entered occasionally, shows data from the db);
As for reading and managing data I'm good because all of them are written to the DB by Server and read by the Interface. But I have an issue: I want to be able to execute actions from the interface such as "Send new config to the client". How should i approach this? Creating a new socket in the interface project and sending it to the client sounds really bad.
Desired solution would be that the Interface somehow "tells" the server to perform such action. How to achieve that?
When your client sends data to the server, have your server send a response (if you are not doing this already). The response can contain any commands that the client needs to perform (such as update client configuration).
Now, your WebForms program needs to inform the server of whatever actions it needs clients to perform. This can be done in many ways, depending on how your system is set up.
The WebForms program can write to the database and have the server read from it.
or
The server can listen on a socket and the WebForms program would connect to this socket. If the WebForms program does not know where the server is, the server could write its address (DNS name/IP address) to the database, and the WebForms program would retrieve this address from DB and connect.
or some other way that suits you
Related
I'm developing an android game using unity. I have a pi-server (static ip, port forwarding, apache 2, php, mysql and phpmyadmin all set up) and I want to use it to store scores from my app to it as well as retrieve top scores for a leader-board. What code should I use to facilitate the kind of communication I want? To be more precise how would I send through the sql code to the server and read the data?
It is the first time I'm attempting to do this kind of thing, so sorry if it is something obvious. Other info: port 80 is set for forwarding, the database is called "game_scores", table is called "highscore" and the table consists of 4 columns: id, username, score and date.
Although it's possible to have your app communicate directly with the MySQL database on your server (through port 3306, not port 80), the standard way to facilitate this kind of connection is to instead implement a web service (REST API) that runs on your server, listens for HTTP requests from your Unity app, and connects to the database to respond to your app with the data it needs. Communicating with your server through HTTP (or similar protocols) creates an abstraction layer that allows you to change or swap out your server or database implementation in the future without changing the client. Here's a decent-looking tutorial that describes how to create a simple REST API with PHP and MySQL. Once you create the REST API on your server, you can send requests to it from Unity using UnityWebRequest.
I'm trying to create a WCF service for our existing product.
The service should provide normal "webservice" features (one-way), but also act independently.
Sample scenario:
The client connects to the server
The server saves the client in a collection
Now I use an admin client / database entry to tell the client to do sth. (For example change config for log4net/NHibernate)
I've read some things about callbacks (mostly a chat system), but I'm still not sure if this will work.
Now my question is, will WCF be suitable for such a scenario or should I use TCPClient/TCPListener?
I want to control application (in my case it is corelDraw) ,I know I should use it's application object and I do this, but the issue now is I want to do this in webservice,
so as far as I understand if I put this code which control the application in the web-service ,my code will try to control the corel application which is on the server not on the client :(
so any hint/advice how could I do this, and control the application on the client not server ?!!!
As you already noticed web service runs on server and only result is passed to client.
Well you have a few options to control client machine over web service... Here is one of possible scenarios.
1. create web service that will provide commands for client
2. create windows service (client) that will consume your web service commands
3. inside windows service then just execute those commands in appropriate manner
Well I have to say this is not the prefered way I would take to automate corelDraw, but if you insist on using webservice as command provider it will do the job.
You need to ask yourself what is the difference between client and a server. Can a client be a server? Can a server be a client?
You make your client with CorelDraw installed to accept web-service request, i.e. effectively make it a web-service server, and then carry on as normal.
Although I would say web-service is not the best way to control such complex application as CorelDraw. I'd look in some other ways of communication between peers, like lower level network communication that would not have overhead of HTTP.
We want to implement a client server application. here is the scenario.
Server listens for client 24/7.
Server accept request for client and save it in DB for further process.
Once processing is done (it may take few hours), Server will response back to client.
in short , client and server listens for each other 24/7.
I want to implement it in C# but i also want that it should be accessibly from all platforms.
Also is it possible in WCF?
I agree with Yuck, this is a basic WCF scenario. There a few articles, videos and tutorials to get you started here http://msdn.microsoft.com/en-us/netframework/dd939784
suppose if i want to develop a windows chat application then a chat server need be developed and client too. after developing chat server apps we can run that apps in a machine and chat client will be running another pc. if those pc is not in same network suppose chat server run in a USA machine and one chat client run in Germany machine and another run in UK machine. in this situation how communication will happen using internet. all the nachine have access internet so how one chat client will login to chat server and how two chat client will communicate with each other. i just want to how data will transfer from one client to another client via chat server. please give me concept or it would be better if anyone give me a reference of a any good .net based chat application where chat server and chat client will be there.........thanks.
Generally? I don't see how this is related to C#, but client-server architecture looks like this:
Client <-----> Server
For something like you're describing where two or more clients communicate with each other, you're just talking about adding multiple clients:
Client A <----
|
----> Server
|
Client B <----
If Client A wants to send a message to Client B, then Client A sends the message to the server with some sort of information indicating that it's intended for Client B. The server then examines the message, determines that it's intended for Client B, then relays that message over its connection to Client B.
This is the fundamental definition of client-server architecture. There are more advanced architectures that mix client-server with peer-to-peer, such as Skype. In a hybrid system, the connection from the client to the server typically only carries control messages (authentication, etc.) and requests for information on how to contact another client directly. The advantage to an approach like this is that it doesn't require all of the communication between A and B to flow through the server; A and B both connect to the server, but they then ask the server how to connect to each other directly, then use that direct connection for the bandwidth-intensive communication.
That's all an aside, really, though. You should read up on client-server architecture independent of any particular language or environment before you start down the road of developing an application.
WCF Web Service with the client polling the service (simple-basic scenario - easy to implement, not very efficient)
WCF Duplex Web Service with the server updating clients when needed (a bit more complicated)
TCP Socket-based solution, hardest to implement but permits much better control. There is a very good example in Matthew McDonald's book "Pro Silverlight 3"