Can I receive a phone call over my modem in C# - c#

I'm working a piece of software that in a perfect world would never lose an internet connection, and I could send an audio feed between two clients flawlessly. My problem is that this world is far from that. In the event of a failed internet connection and a dropped audio feed, my service is effectively worthless.
My question is this:
Is there a way in C# to attach to my systems modem and either make a call, or receive a call, (or preferably both,) and push/play audio to/from two points?
The approach is deprecated, but nearly a necessity in my scenario, and I couldn't find much on Google, so any help would be appreciated.
Thanks ahead of time.

No, modems (dial-up I assume you mean) do not have the ability to insert raw audio on a pots line (perhaps if you rewrite the driver though) but you may want to look into asterisk that has some really cool stuff you can mess with. But to the main point unless you forget the modem and use an ip-phone solution the answer is no.

You should look at using a service like Twilio to handle voice calling. They have a .net client: http://www.twilio.com/docs/libraries

Related

Very simple Client/Server Message networking in C# (.NET and Xamarin/Mono)

I would like to write a simple application to send text messages between a server (Windows) and a client (a Xamarin App running on android), which would remotely control music (played by the server) with basic text commands (like "pause", "skip", "play " ...).
The setup I had tought about would work like this:
When I start the android app, it tries to connect to the server (they are in the same local network using LAN/WiFi, so I'd just use my local IP for that). Then, with the connection established, both would be able to send messages to the other one (client -> server: play this song etc, server -> client: song finished, song not found, etc). Of course, that should be done in a threaded or asynchronous manner so that both applications do not block up their UI. The server would run in the background and wait for the next message, which would trigger an event taking care of doing the requested action.
I already searched on how to do this in a beginner friendly way, but haven't found much that I could work with. I only have basic knowledge on asynchronous/threaded programming, and not enough on networking (in .net). Each solution I found wasn't made for a connection to stay open but rather "read stream, send answer, close connection" (which is not what I want) or was far to complex.
I know that there are countless tutorials available, but I simply couldn't make up how to use them for my scenario. Example Code or easy to understand explanations on how to accomplish things like keeping the connection open in a non-blocking way, and how to send and receive a complete, self-contained message, because I can't quite wrap my head around that (if I just read a fixed size of bytes, how can I be sure to get exactly one message ?).
So, I'd be grateful for every tip showing me in the right direction, like for example which of the many classes would be best to use for this (there seems to be an awful lot of them, without notion which is suited for what). I apologize if this question seems rather dumb, but I'm an absolute beginner in this. Thank you very much in advance !
Figured it out myself, after some more research. System.Net.Sockets.UdpClient is working like a charm, and, more importantly, available and working on both platforms I want to target, so I will just go with it.

C# server sends UDP packets to a Java Client

im working on a project where i should transfer data from a c# server to an Java client (running on android device).
i need to use UDP protocol for a real time data and to maintain performance.
searching the web. didnt find any similar example and i really dont know where to start.
can you please suggest if this can be done ?
Thanks in advance.
Yes, it can be done. That's one of the beautiful things about the Internet protocols: support for standard sockets is so widespread and common that disparate devices running vastly different CPU architectures and software environments can interoperate with nearly no trouble.
Please make sure that UDP is really the best tool for the job. Do you need reliable delivery? Do you need in-order delivery? How much packetloss can you tolerate? How much packet re-ordering can you tolerate? Will your application handle 540 byte packets as gracefully as it will handle 1500 byte packets? Does your application need to protect against man in the middle attacks? How?
TCP is an incredible protocol. Many attempts to use UDP "for speed" wind up re-implementing many of the things that TCP provides for you already -- but most re-implementations are not done nearly as well as the real thing. Please don't be so quick to dismiss TCP.
To get started, just about any network tutorial for Java and C# should include something like a chat or echo server, the network programming equivalent of "Hello World". And that'd be good enough for a simple environment. If you intend for your server to handle dozens of clients simultaneously, it'll be more work, and if you intend for your server to scale into the hundreds or thousands, it'll be a different style of programming altogether.
Have you tried reading this:
http://nickstips.wordpress.com/2010/09/03/c-creating-and-sending-udp-packets/
The client is irrelevant, it can be Java, C++, or any other language/platform. Doesn't matter.
The protocol is still the same.
Hope this helps.
Try the Oracle Documentation as a starting point with UDPs, there you can find an example which i in java but as mentioned the idea of the protocols is to support a language independent communication.

handling multiple clients c#

I am working on a project where i need to connect with multiple clients and every client is streaming live screen capturing to server. Server show that.
What would be the best approach for that.
Thank You
You can use WCF in streaming mode for the video, but I doubt it is a good solution.
I think that going for pure sockets is better, to get the performance required. Showing a live video stream is also not really a limited operation (which is what WCF is built for), but rather something ongoing.
My suggestiion is to:
Use a pure TCP socket for the video stream for a start.
If that gives problems, you can switch to UDP. It is better to skip over any lost packages for live video, but with UDP you have to track package ordering etc. yourself.
If you need control operations, use a separate WCF service for that.

Using SerialPort class for modem to modem communication

I'm rewriting a legacy app that sends pager messages via TAP and modems. So I'm having to write a new TAP client in C#. Using SerialPort is trivial but I'm not sure about how to handle conditions such as:
excessive ringing with no answer
no dialtone
busy signal detection (I understand that this isn't enabled in every modem so this is optional)
remote modem answers
Then also how do I read received data in a synchronous manner? TAP is synchronous so I will be issuing commands and then expecting some type of response from the remote machine. I think my biggest issue is figuring out how data will be terminated. Is it standard for modem data to be terminated by a CR or maybe CR-LF?
Some pointers would be great and any references that I could go read myself is wonderful too.
Is this a question regarding Serial Communication or the TAP? I've never had to work with TAP, but I have had to work with serial communication hardware (albeit quite a few years ago.)
I just found this PDF specification document and I searched for "terminat". It brings up 8 different words with that series of text, 7 of which appear to be in reference to your request.
I'm not sure of how much experience you have with serial communication or legacy communication systems & hardware but you may find HyperTerminal to be immensely useful and it is part of Windows. There is other serial/terminal software out there, but HyperTerm is free and simple to use.
You can use HyperTerm to send and receive codes to your devices and inspect the data that is sent/received. Then, you can use the communication dumps to reverse-engineer the TAP communication.
-- EDIT --
In regards to interacting with the modem, I'd research a bit about the Hayes command set. Hayes was a company that made modems in the early 80's. According to what I've read their modem commands have become pretty standard ever since then. Glancing at the available modem commands, I think there is a solution for your questions but you may need to do a bit of experimentation.
I'll be honest, I've never had to work directly with modem hardware, so the information that I am providing is based off of the research I've found this afternoon. These tips are what I would assume and attempt if I were in your shoes. For more information, google "Hayes Command Set" or check this article.
Hope that helps.

Monitoring TCP traffic that contains specific strings in C#

Recently one of my machines was infected with malware using IRC to communicate back to it's command and control center.
This just sparked interest within me to see if there was a program I could create in C# that is capable of monitoring traffic over TCP that contains strings such as PONG / NICK / USER (strings the irc rfc needs to communicate), and then can tell me the process that that traffic is coming from.
It would be an interesting learning experience for me, and it's something that I want to attempt.
I've done some research and I found something that did make use of WinPcap but i think I'd like to avoid a solution using pcap if possible, can anyone send any suggestions my way?
I know I may be able to view connections between my computer and other hosts using System.Net.NetworkInformation.TcpConnectionInformation and possibly IPGlobalProperties but I'm not sure if there is anyway I can view the information in realtime, or easily trace it back to a process on my PC.
Thank you.
This is going to be hard. The API you need is native, Windows Filtering Platform (WFP). According to Microsoft, this is not accessible from C#, you would have to wrap it in C++/CLI first.
See here and here for discussion. The second thread has some 'could be useful' stuff for you.

Categories