views:

304

answers:

4

Hey, we're working on a peer to peer comm software that would allow a number of grocery stores to sync their inventory with what we call "headquarters". To so this, we're thinking WCF+WPF, and no IIS and web services. My experience with WCF is basically zero, so my question is whether a TCP comm solution using WCF would work. The data that's being transferred is quite limited, about 2MB for a compressed plain text file (so we're sending binary data!), and this is done once per day only. So bandwidth/load shouldn't be an issue here. The idea at this point is to have a WCF "server" running at HQ. Stores make themselves known to that server and then send files back and forth (simliliar to a chat application). What I'm not sure of: does every store need to have a WCF "server" (or endpoint)? How would the server (=HQ) send a file to one of the clients (=stores)? Every store can send a file to any other store, and the HQ, and every store can also "request" a file from any other store/HQ.

Two limitations: None of the machines/computers involved can run Windows server for budget reasons, and as stated before IIS is a no-go.

+2  A: 

You don't need to host WCF in IIS, but is there any particular reason you don't want to do that?

You can host WCF in a ServiceHost, but then you need to build, maintain and deploy a lot of server/service features that IIS provides for free, such as application process recycling, activation-based hosting, etc.

In any case, it almost sounds like you need peer to peer networking. You can do that with WCF using the NetPeerTcpBinding.

Mark Seemann
Thanks for your reply. So that does mean each client also needs a "server" (endpoint), e.g. A WCF hosted in a Windows service? I was hoping that only one machine would host the WCF service, and all other clients can communicate with any other client thru that. Yes, IIS would come in handy. Lame excuse: the customer just doesn't like it.
John
You can have one server and use what is called a Duplex binding, which means that the client registers an endpoint with the service for the duration of the 'session'. However, in such a hub-and-spoke topology, clients can only talk directly with the central server, and not with each other.
Mark Seemann
Does NetPeerTCPBinding allow a client to send something to one specific other client, or is there no control over who receives the message? As I understand it this is a broadcast, so all clients receive the message. Thanks again for your time.
John
A: 

If you have an opportunity to redesign your application, I suggest you do. You can throw strings around in WCF but if you can create a data contract you can keep all your communication strongly typed.

If you have access to windows server 2008 then the new IIS can host your WCF even if it isn't using tcp. Otherwise you just need to write an application that opens a service host, which you would usually wrap into a windows service. But as @MArk Seemann pointed out, you get lots of freebies by running your service in IIS.

Don't have any experience with the PeerTcpBinding but I can tell you that the NetTcpBinding is nice and fast plus it comes with all sorts of goodies like encryption and authentication if you want it.

Spence
Thanks. I agree about IIS. They don't want/can't afford Win2008, however, the most that they can do is Windows 7 + IIS. What freebies does IIS offer when using TCP that a windows service does not? As I said, load is very low and is not an issue. And there's a guarantee that only one client is "talking" at a time, i.e. sending a file. Thanks again!
John
You're basically responsible for creating, monitoring hosting etc your service in WCF, as well as ensuring it has the right configuration and you get no tool support. IIS will host just a DLL with a service in it, has a tool to help configure the service, raises events etc. if the service is online and automatically restarts it if it crashes etc. YOu have to do this yourself if you don't use it.
Spence
+3  A: 

If you are only sending files back and forth, I might question whether or not WCF even makes any sense. Have you considered just using a file transfer protocol, like scp or sftp?

Every machine will have to accept connections and have a file drop location setup, and then yuor application will have to monitor that location for new files. I love WCF in general, but a file transfer protocol is going to have a leg up if that is all you want to do.

Chris
I agree. In my point of view WCF is more focused on message exchanging rather than file exchanging.
born to hula
+2  A: 

If you direct all of your traffic via the server then there's no reason why you couldn't achieve this with WCF. The server would host WCF services in IIS with the stores having a client that was able to upload and request files. With this method, stores would not be able to directly transfer fiels to each other, but they would have to do it via the main server, which would suit your needs if you don't have the budget for the other scenario.

If all transfers are made once per day, the requests for files would be made with each client requesting what files they require, followed by each client uploading any files that are required by the server or any other client. The final step would be the server distributing the required files to each client. Obviously, this is a simplified view of it, the actual process may require some more thinking.

Tanner
Yes, that is what I'm thinking as well at this point. Have one server to handle all the traffic... however, the server must be able to send files to the clients without them having to request them. So the WCF server must somehow know if the client is online/connected. Is that possible?Thanks!
John
If the server can't connect to the client, you can handle the specific exception that is thrown and re-try at a later time. you would have to have some sort of timer for the process running on your server.
Tanner