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.
Related
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
I currently have a .Net remoting service that can be accessed by different ways:
Locally through an IPC channel
Remotely through a TCP channel
Locally through a TCP channel
I need to known, in one of my service method, if the call has been made locally or remotely(depending on a licence, I've to send smaller data remotely).
I can't find a way to find this.
I've already a custom IServerChannelSink, I thought that I can detect which type of channel is used of this call, and if it's a TCP one, check it's IP, but I can't find how.
Do you have any idea about how to check if we have a local call or not?
Thank you for the help
This question shows how to identify the client using its IP address. As you've already got a custom server channel sink it should be fairly straight forward.
I have a server & a client. The client is my Android phone. The server is my PC running Windows.
I'm needing to find out the best programmable method of sending a short string to the PC and having it displayed real-time.
Please keep in mind the only languages I can program in on my server-side is VB.NET, C#, and C++ (and my experience with them is in that order).
Edit:
I don't care about security or anything. Both devices will be on a private wifi network. I can't rely on 3rd party applications though, considering the computer running the server will have very little RAM.
If it's just a simple string, and you don't care too much about security or reliability, you could go about this using java.net.Socket. Create a Socket, giving it your PCs IP address, an open port, etc. Write up an application on the PC to listen to that port, and handle the data as it would. I have no idea how you would go about doing the server-side part, as I've only really used Java, but it shouldn't be that hard if you're going with raw sockets. With the Socket on your android, create an output stream, and pass the string through that stream.
If you need a more secure, more reliable, more standard protocol of delivering a string, I'd probably go with HTTP. You might have to read up more about it, but they're better overall. Sockets aren't a whole lot simpler, though.
You can write a .NET project which communicates with sockets. Your PC could listen to a given port and your phone would access that port. This article might help you to learn more about .NET socket programming and you will be able to use C# or Visual Basic as you want.
I was wondering it it was possible to relay a socket object in either C# or Java? (Preferably C#)
I have lots of little programs i make and host them on my home pc, but my pc is behind a router, so i have to forward a port on my router every time i want to make a new application. So is there a way to send a tcp connection to another application on the same computer? for instance i get a connection in with the first line of text being RELAY::21005 which would then forward that port to localhost:21005 ?
Any help, tutorials, code snippets would be much appreciated. Thank you! :)
One problem you might face with your suggested solution (first line identifies target port) is that you'll have to change all of your client programs to send that first line. That's easy for programs you've written yourself but not so convenient if you want to connect to your PC's web server or ssh daemon etc. It's not impossible of course, but does make it hard.
I'd suggest your routing server listens on two ports - a control port and a "normal" port (I can't think of a better name at the moment). You would send control messages to the control port to indicate "until further notice redirect all incoming connections on the normal port to port nnnn". That avoids having to manipulate client protocols.
I don't know enough C# to provide advice about a C# solution, but in Java I'd simply do something like:
while (true) {
acceptConnectionOnNormalPort()
connectToTargetPort()
startThreadCopyingDataFromAcceptedPortToTargetPort()
startThreadCopyingDataFromTargetPortToAcceptedPort()
}
You'd not be able to scale that easily into thousands of connections...
K I take back my comment, check this out:
http://msdn.microsoft.com/en-us/library/aa395195.aspx
Using this requires the port sharing service to be up (it is disabled by default):
The Net.TCP Port Sharing Service is available on all operating systems
that support .NET Framework 3.0, but the service is not enabled by
default.
All of this is only useful to you if you are using WCF services tho.
The easiest approach IMO is to use ssh tunneling. As I wrote in my comment, there are lots of questions on SU that will show you how to do this.
But assuming that you want to program something ...
You'll need to create a client and a server. The client will have threads that call accept on whatever local ports you want to open. When a connection comes to a port, you create another thread that opens a connection to the server and continually sends data over the wire.
The server program listens on a single port, which you open in your firewall. It waits for connections on that port, and when it receives one it opens a connection to the specified local port. Then it shuffles bytes from one to the other.
The only trick is that you have to define a protocol for specifying the destination port in the client-server stream. Simplest approach is to write a two-byte integer at the start of the stream.
Yes, it is possible to relay a socket.
You can use TURN http://en.wikipedia.org/wiki/Traversal_Using_Relay_NAT
Some of TURN library/application:
pjnath
turnserver.sourceforge.net
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.