Sending & Receiving "Nudges" via tcp? - c#

I'm tyring to add a feature to my app that sends a nudge to all users of my program (family members inside the house), and when they receive the nudge the window of my app on their computer shakes for a second...
Can somebody please suggest how i'd have to go about this? I've never worked with tcp/ip before.. Is this what I should use, or is there something better?
I have tried to come up with my own solution however none of the samples ever work. So I thought maybe the people on SO might know of other ways?
Thank you :)

If this is just an "in-house" (pardon the pun) application, and you're all on the same network, you might consider sending a UDP broadcast packet. Each instance of your application could listen for a packet on a particular port, and when the correct one is received do the window shake thing.

You might consider UDP for this. Since you can broadcast/multicast via UDP it may be more suitable for this sort of application. There are downsides - UDP transmission is not reliable or guaranteed in the same way as TCP.

I'd go with a good XMPP Library. Maybe Jabber-Net?
You'll also have the added bonus of being able to connect to Google Chat and now Facebook chat later.
You haven't specified if presence in your case requires a server or not. If it is client/server oriented, using XMPP gives you the server side for "free" as a bonus.

Related

Basic P2P chat application on the .NET framework

I am attempting to make a chat application on the .NET framework that will be able to communicate over the internet and not just LAN. I would like it to be P2P as to not require a central server. I don't mind which protocol it uses (UDP, TCP, etc) so long as I can send messages to almost any given IP.
All I would like to know is how to send data to another IP I know of, nothing else. I've searched around but the code is too complicated for me. (For example I've looked at the source code for torrent clients).
Help will be appreciated a lot thanks.
P.S.: I've heard about a method called UDP hole-punching if that sparks any plugs.
There is a small issue with your plan.
The server-centric approach does not serve only as a slow middle man, but also as a central point with known address to connect to, an anchor in the sea to attach to and clients connect to the static IP/name of the server.
Usually, users do not care what is their IP address on the internet...
So at the minimum, the server is good to get list of clients.
Nowadays you can use some services from Microsoft or Google or other.
Now rest of the P2P communication of clients between NAT comes with more learning: TCP_hole_punching
I would suggest reading all that stuff then look for some code or library that does it.
Here is older topic similar to yours looking for the hole punching library: tcp hole punching library
I have answered similar kind of things here Peer-to-Peer application using java, let me know if it helps or if you have any specific question about this. Basically you need NAT traversal, so you would find many different ways to achieve this based on your need. Even you can achieve this simply configuring your router by enabling UPnP.

How can I ping a Networked AV Receiver with UDP?

I've been working with a Denon AVR-X1100W in an effort to find out whether or not I can ping it over a local network. For this, I am using C# in order to make a simple program.
How can I ping this type of device? A traditional ping command doesn't work, however, as it lacks an actual web server internally. I understand that a socket needs to be opened and, from there, a specific message sent with UDP.
Beyond creating a socket, I am unsure on how to continue.
I managed to find a great JavaScript-based library, denon-avr, that helped me connect to the receiver.
While this resulted in a change from C# to JavaScript, I found using JS to be much more agreeable in terms of development.

C# server-side socket sender?

I'm trying to muddle my way through setting up a server with a socket port, but I can't find any good references/examples for my situation.
Pretty much all server-side examples go:
Listen for socket to connect
Receive msg from client
Reply to client
End communications
What I want to do is:
Listen for socket to connect
Begin sending data intermittently (as data updates arrive)
Continue until the connection is broken
I'm considering taking the standard example, simply skipping the receive, then setting up to repeatedly send (based on receiving events inside the server), but I don't have high confidence in that and I'd like to know what the standard approach to this problem is.
Also, if I want to have multiple ports open do I have to manually assign IP ports, or can than be done automagically?
You can find one of the libraries here. There are some samples in demo project and I think CustomWireProtocol is a sample project that can solve your problem. You can change the client code to send continious messages to server.
I'd recommend looking into Nanomsg by the author of ZeroMQ. Here's an example from a .NET binding project on github:
https://github.com/mhowlett/NNanomsg/blob/master/Example/Program.cs

C#, WCF, want to make a chat application, what binding should I use? maybe some examples?

I am looking forward to make a sort of a chat application using C# and WCF, yet before I start I wanted to clear a few things, so that I don't get carried in the wrong direction. :)
the application should be able to both make event ( send messages ) and listen to events ( receive messages ), therefor if I understand it right, the application should be both the client and the server at once?
what binding should I use? If I understand right, basicHttp binding hard to configure and is used when a WCF app needs to connect to non-WCF app? While for connecting two WCF apps its better to use NetTcpBinding?
how would this applications find each other, considering that they are running on different machines? should there be a central server, to which the app would connect first, saying "I'm user123, my IP is that and that, I'm free for chat" and look for other user IP addresses there? Or is there some other ways for apps to find each other without the central server?
maybe you could direct me to some examples or tutorials on this topic? ( tried googling, no luck ).
Thanks! :)
If your peers (machine that can operate as a client & server) are going to be behind NATs/firewalls then you will have a very very tough time building a chat application using WCF. If the peers will all be on the same network WCF is workable.
To write a chat application from scratch using WCF you will be re-inventing the wheel. Why not employ an existing protocol that's been designed precisely for the purpose such as XMPP. There are XMPP libraries around for .Net. You will need a central server but if you use XMPP you could feasibly piggyback onto one of the many existing free servers.
You can use netPeerTcpBinding.
See also:
http://blogs.interknowlogy.com/2009/08/05/building-a-really-simple-wcf-p2p-application/
http://msdn.microsoft.com/en-us/library/bb690929(v=vs.90).aspx
http://www.codeproject.com/KB/WCF/Chat_application_using_WC.aspx
There is no right and wrong answer to your question - it all depends on what you require. You then can choose the best architecture for your needs, and then the best technology for that architecture.
There are two things to consider - how will users find people to chat to, and then once they have found someone - how do the applications connect to each other.
For users to find each other, you either need to connect to a central server, which will then show a list of all connected users, or users need to enter the IP address of the person they want to chat to. Note that some firewalls will block incoming connections in this second case, so this may not be feasible in some cases.
Next, once you have found the person you wish to chat to, you need to decide whether messages will route directly to the other user, or if you want to continue to go through a central server.
If you choose to go through a central server, then your application will be functioning as a client, and will therefore pass through firewalls without a problem. However if you connect directly to the other user, both copies of the application will be acting as a client and a server (P2P topology), and therefore firewalls may be an issue. Having said that, you could designate one of the applications to be a server, with the other acting as a client, in which case only the server side needs to worry about the firewall.
Without knowing exactly what you are trying to achieve, it is hard to recommend which architecture will work best for you.

.NET and P2P - writing a P2P messenger

Does anyone have any advice how to write such app? Or maybe knows some nice tutorial? I would like to use System.Net.PeerToPeer namespace, but everything I can find about it is MSDN which I can't read without getting mad. Or maybe using "old-school" TCP/IP would more efficient?
I will appreciate every piece of advice. Every sample code I will shower with gold ;)
And please, don't send me back to Google for I have searched for a long time for sth useful - maybe inaccurately but time is running out and I really need some help.
[edit]
What about the Brunet library? Has anyone used it?
There is a sample at MSDN that you may find interesting: Peer Channel Chat.
Quote from the page:
The Chat sample demonstrates how to
implement a multiparty chat
application by using Peer Channel.
Messages sent by any instance of a
chat application are received by all
other instances.
The Chat sample is not based on the
concept of client and service. It is a
true peer-to-peer application with
each instance acting as a peer of
other instances. Each instance can
send messages to other instances and
receive messages from other instances
using the IChat duplex contract.

Categories

Resources