I am creating an application using Apache Thrift technology http://wiki.apache.org/thrift/. I knew how to create a connection between client and server and I can call a function stored in server by client.
But now, I want to send a message from client to server like "Hello from client", and the server have to recieve and print it. I can do it by using the .NET framework and multi-threading waiting for message. But I would to use the Apache Thrift Technology because of my lecturer's offer.
After server recieved this message, it can reply it to client something like "I got it", and client side will get this message.
So how can I do that by using Apache Thrift, please give me some advices or some reference materials on it. I would like to use C# to create my application.
Thanks in advance.
Since you did not post any code, I can only give you the generic outline.
There are two resources worth looking at when starting with Apache Thrift. First, there is the tutorial, which is about a small calculator app demonstrating the basic principles. Theoretically, this should already cover all you need for your task.
But wait, there's more: The other resource is the Thrift Test Client/Server program, which besides its primary purpose also gives a good sample and showing a number of techniques regarding the different protocols and transports.
The creation of a client with C# boils down to this:
// put together a protocol/transport stack as required by the server
TTransport transport = new TSocket("localhost", 9090);
TProtocol protocol = new TBinaryProtocol(transport);
Calculator.Client client = new Calculator.Client(protocol);
// make sure the transport is open
transport.Open();
// call a method via RPC
client.ping();
Again, I encourage you to make your question more specific, if you have a concrete problem. The above sample code can be easily found in the docs via Google 1), so I bet that is either not the real problem or you may be just looking for someone doing your homework for you.
1) Just look for "thrift tutorial" and click the very first entry in the search results.
Related
I am looking to write an application that will take client data from a database, transfer it to our server application, manipulate that data and then pass it back to the client. I would like this to be as seamless as possible and as secure as possible. Also, the manipulation part of this could take several hours. The format of the data will be different for each client. To make the application as easy to maintain as possible, the simplest solution too.
What methods would people recommend for achieving this?
WCF will make your implementation easy. It looks like you are wanting to have the client -> server -> client communication asynchronous, since the server process can take hours, you don't want to block your client that long.
You probably want to define a server WCF service contract to allow the clients to load data to the server. You also want a client side WCF service contract that the server can use to send the results back when the processing is completed. OR you can have the server send a small message to the client WCF service telling it that "results are ready, come and get them when you are ready". You will need to coordinate this with some type of ID; the server tells the client to use this id when it wants to collect the results.
Have a look for duplex, asynchronous and peer-to-peer communication topics in WCF. There should be plenty of examples if you google around.
Please take a look at WCF framework of .NET 4.0.
1/backup the database in prod
2/download it,
3/restore in local
4/modify,
5/backup in local
6/upload
7/restore in prod
to download in https or sftp, with ip restriction
you can compress the database before download it too
I'm working with asp.net MVC. Now I don't know how to send data form a server (using asp.net ) to another server using (win32 console command line). Plz help me.
P/S: Is there any security hole in this method.
Well generally the case is that most ports today are blocked behind firewalls so setting something like that up with winsock, is outdated. If you are tring to connect two servers there are many options, You could look into the System.Web.WebClient,System.Net.HttpWebRequest,Microsoft's Sync Framework, Rhino queues but heres the run down on the first two.
In short, HttpWebRequest gives you more fine grained control over your
request. WebClient does not. It encapsulates most of the stuff for you.
WebClient is very useful if you want to do specialized, one-off tasks, eg:
download file, do forms post etc.
HttpWebRequest is useful if you want to do more complicated stuff.
The WebClient is especically simplified, we can use it's DownloadData,
DownLoadFile to retreive file/stream from remote webserver. Here are some
tech articles and resources describing using webclient or webrequest:
Hosting WCF services, WebClient
here
and webrequest here.
You have two servers trying to communicate. If you are going to use IP (I am assuming you will since you mentioned Winsock) you must choose between these two protocols:
TCP
UDP
Once you've decided which one to use, you can write a server process (the console application) that listen to a specific port (TCP or UDP port depending on what you've chosen) that will serve your client process (the ASP.NET application).
If you use TCP/IP, you use sockets to communicate. If you use UDP/IP, you will send and receive independent packets.
Here is a TCP/IP client/server code sample in C# you can use. You will wrap and run the client portion of this example is a class you can access within ASP.NET MVC.
Here is a UDP/IP server code sample in C#.
Regarding your question of the security of this approach, the question does not provide enough information to answer it properly. You will need to provide more information.
I would like to have a client-server application written in .NET which would do following:
server is running Linux
on the server there is SQL database (mySQL) containing document URLs
What we want:
- server side would regularly crawl all URLs and create a full text index for them
- client side would be able to perform a query into this index using GUI
The client application is written in .NET using C#. Besides of searching in documents it will be able to do a lot of other things which are not described here and which are done client-side very well.
We would like to use C# for the server side as well, but we have no experience in this area. How are things like this usually done?
Clarifying question now based on some answers:
The thing which is most unclear to me is how client-server communication is usually handled. Is client and server usually using sockets, caring about details like IP addresses, ports or NAT traversal? Or are there some common frameworks and patters, which would make this transparent, and make client-server messaging or procedure calling easy? Any examples or good starting points for this? Are there some common techniques how to handle the fact a single server is required to server multiple clients at the same time?
To use c# on Linux you will need to use Mono. This is an open source implementation of the CLR specification.
Next you need to decide on how to communicate between server and client, from the lowest level of just opening a TCP/IP socket and sending bits up and down, to .Net remoting, to WCF, to exposing webservices on the server. I do not know how compleat WCF implementation is on mono, also I think you may have issue with binary remoting between mono and MS .Net .
I would suggest RPC style WebServices offer a very good solution. WebServices also have the advantage of alowing clients from other platforms to connect easily.
EDIT
In response to the clarification of the question.
I would suggest using mono/ASP.NET/WebServices on the server, if you wish to use c# on both server and client.
One assumption I have made is that you can do a client pull model, where every message is initiated by the client. Using another approach could allow the server to push events to the client. Given the client has the ability to pole the server regularly I don't consider this much of a draw back but it may be depending on the type of application you are developing.
Mono allow execution of c# (compiled to IL) on a Linux box. Mono ASP.NET allows you to use the standard ASP.NET and integrate into Apache see http://www.mono-project.com/ASP.NET and finally WebServices allow you to communicate robustly in a strongly typed manner between you client and your server.
Using this approach negates most of the issues raised in your clarification and makes them someone else's problem.
Sockets/SSL - is taken care of by standard .Net runtime on the client and Apache on the server.
IPAddress/ports/NAT traversal - Is all taken care of. DNS look up will get the servers IP. Open socket will allow the server to respond through any firewall and NAT setup.
Multiple Clients - Apache is built to handle multiple clients processing at the same time as is ASP.NET, so you should not encounter any problems there.
As many have already mentioned there are a number of thing that you have mentioned which are going to cause you pain. I'm not going to go into those, instead I will answer your original question about communication.
The current popular choice in this kind of communication is web services. These allow you to make remote calls using the HTTP protocol, and encoding the requests and responses in XML. While this method has its critics I have found it incredibly simple to get up and running, and works fine for nearly all applications.
The .NET framework has built in support for web services which can definitely be called by your client. A brief look at the mono website indicates that it has support for web services also, so writing your server in C# and running it under mono should be fine. Googling for "C# Web Service Tutorial" shows many sites which have information about how to get started, here is a random pick from those results:
http://www.codeguru.com/Csharp/Csharp/cs_webservices/tutorials/article.php/c5477
have a look at Grasshopper:
"With Grasshopper, you can use your favorite development environment from Microsoft® to deploy applications on Java-enabled platforms such as Linux"
Or see here
The ideea is to convert your app to Java and then run it on Tomcat or JBoss.
Another approach: use the Mod_AspDotNet module for Apache, as described here.
This Basic Client/Server Chat Application in C# looks like a kind of example which might be a starting point for me. Relevant .NET classes are TcpClient and TcpListener
I need to know if there are any tools to figure out the interface to a TCP client. My Company has purchased a 3rd party tool and we really like the Server side and most of the client side.
I would like to see if I can figure out the calls that the client side makes to the server so I can create the client side functionality we want.
I have been able to figure out what the port number and protocol that the client communicates with the server on. Since we host the server, I have full access to that too.
Any ideas on how to get hold of and execute the methods that the client app is calling on the server?
I am not that good at java, so I would like to use C#.NET if at all possible. Does that sound feasible?
NOTE: I have done something like this before (connect to a 3rd party Java Based Server with a custom .NET client) but that time I had a bit of documentation to get me started. This time I have nothing.
Any Help will be greatly appreciated.
Also, if you know better tags for this please post them as comments (or just re-tag if you have the permissions)
If you're trying to reverse engineer the protocol so you can write your own client to the server, get Wireshark. You can use it to follow the conversation between client and server.
You could attempt to decompile the library. That should give you all of the low-level info that you need.
You could also use TCPMon to grab the exact message text passed between client and server.
Is there an easy way to create an IM bot on multiple im networks (aim, gtalk, yim, etc) that can accept and interpet specific commands sent to it to perform a server related task?
Lets say for instance I have a website for managing an rss feed. I want to send a command to an IM bot to add another feed to my collection. the IM bot would associate my screen name with my account from prior setup on the website.
I have done some internal bots for my company using the XMPP (Jabber) protocol, I've used the agsXMPP SDK and the Jabber.NET client libraries, I was looking for APIS to work with YIM, AIM and Windows Live Messenger but I've found only COM exposed APIS, nothing for .NET...
But an idea comes to my mind, with the XMPP Protocol you can configure a local server with IM Gateways, that allow users to access networks using other protocols through your server
I use eJabberd, you can install a variety of transport gateways to connect with other IM protocols (AIM, MSN, ICQ, GTalk...
To GTalk you can connect directly using the libraries I mention...
A sample ICQ gateway:
The short answer to this question is yes this can be done relitivly easily. Sedning and receiving IMs sending, receiving and interpreting requests from the network you wish to communicate on and there are libraries available for each of the major IM protocols to make this easier.
For messenger you can try the DotMsn library, I have used it in the past but at that time it was still quite new and I have not used it since so I can't vouch for it's quality.
Jabber uses the XMMP protocol which is an open-standard so there are bound to be plenty of client libraries available.
If I recall correctly Google Talk uses this protocol or a modified version thereof.
I dont have experience with c# but I have written one for AIM and Gtalk using PHP. http://www.imified.com/ is the best place to start if you looking for a easier way to write an IM bot.
Basically you create an account in imified.com .
Name your bot and link a script.
When ever a message is sent to the bot, imified.com automatically runs this script.
Here is a link for you get you started!
We have professional .NET/COM/VCL library for MSN/Yahoo/ICQ/AIM/GTalk/Jabber. Please take a look at http://www.imcomponents.com/ if you like.