UDP broadcasting in windows phone 7 - c#

I am working an application in windows phone 7 that must detect the devices connected to particular port no or network. I have desktop application that is implemented in c++ that uses UDP broadcast. I read some articles and know windows phone 7 doesn't support UDP broadcasting. I have tried UDP multicasting in WP7 but due to desktop application have implemented in UDP broadcast, I am not able to do that.
Help me Guys...........

You can use socket.ConnectAsync with e.Buffer containing the message you want to broadcast. In this case, the message will be sent automatically when connection is established. More information about this trick you can read here

You could send a broadcast packet through just SendToAsync method by using limited broadcast IP, not local broadcast IP(such as 255.255.255.255) This means, if your NIC device is in 192.168.0.x IP range, you should shoot a packet to 192.168.0.255. (this IP might be vary on your netmask setting)
However, it works.
Additionally, response back is also allowed but FOR 5 SECONDS ONLY. Your host received a UDP packet from Windows Phone 7.1 device, the host should response back to the port that UDP packet came from, IN 5 SECONDS. Unless, Windows Phone will close the port then, and it has to be gone.
It's very tricky, weird, and ununderstandable(like this word) way.
but it works as far I know.

Related

UDP Connection using Windows Networking

I'm trying to create a Unity Program that will read from a socket that's sending UDP packets, and create in game changes accordingly. I was able to process data great with the UDPClient class, but then when I switched platform to Windows (I need it to be this because it's running on Hololens), the UDPClient was not recognized and I had to switch to the Windows.Networking API. I've found some examples online on people accepting UDP in Unity like these:
https://forums.hololens.com/discussion/578/hololens-udp-server
https://forums.hololens.com/discussion/7980/udp-communication-solved#latest
But even when I try them unedited (with the exception of ports and ip addresses), I get nothing when testing with my Packet Sender app. Can anyone point me in the right direction? I'm a little confused by these examples as they don't use the infinite loop I'm used to using in sockets, and instead use some sort of weird event handling.
UWP apps are not allowed to receive UDP packets from local host. You need to run your packet sender app on another machine. See this:
See this: UWP app doesn't receive UDP Datagram from a .NET desktop app on localhost

Capture incoming packets on port opended by other application

I'm considering interfacing my application with my VOIP system. My VOIP comes with client application that registers with the VOIP server and when acall comes the app displays call info on computer's screen. I identified local port that listens to the VOIP server. I identified the packet that contains the phone number of incoming call. I identified hex position of that phone number within the packet. So now I want to listen on the Socket for a Stream and create an event when expected packet comes. There are two questions:
Will Windows allow me to listed to packets coming on a port opened by another application?
I've never written Socket listener code. Can you refer me to an example or a tutorial?
One possible solution would be to create a man-in-the-middle application:
Client Application <----> Your Application <----> VOIP Server
Your application will act as a proxy between the Client Application and the VOIP server and at the same time do whatever it wants with the data.

Android UDP broadcasting works but direct IP not working

I've published an Android app which communicates with a C# server app via UDP. I've implemented an "Auto Connect" feature which does broadcasting and receives an answer from the server. Once an answer received by phone, the phone app holds the sender IP and sends subsequent messages to this IP directly. Also there is a Manual Connect feature which sends data to the IP address the user enters (which is the local IP of the PC running the server app).
So, everything works great for lots of users but some users reported me that when they use manual connect, it never connects; when they use auto connect, the server gets the broadcast message (seems connected) and the phone receives the answer but afterwards none of the (direct) messages will be received by the server app. The common point of these users is that their PCs are connected to the WiFi router by wire and their phones are connected by wireless. I've tried the same thing on my network but again it works for me without any problem.
May it be because of having multiple network interfaces (both LAN and WLAN)? I've been searching net for 1 week but no success.
What should I do? Please help.
Thanks in advance.

how to do point to point communication in windows phone 7 over gprs

can somebody help in finding out any way about how we can do point to point communication with windows phone 7 and a desktop computer over gprs.
Please it has becoma a showstopper for our project..
Thanks
Edit 1:
Yahya, The computer is having internet and also gsm modem with a network provider sim and the mobile is also having a sim. Where ever they are they have internet and we want to see each other or can send msg to each other over gsm, because when a gsm modem having proper data enabled sim from a mobile network operator is attached to a computer then the computer should able to talk to the mobile over gprs, because the mobile is also holding a valid gprs enabled sim.
Provided that both your endpoints Windows Phone 7 and Desktop have a SIM (or modem with a SIM) inside, you surely know the phone numbers of those SIMs.
if you want to communicate via GSM or via SMS you can send a SMS (Short Message) from one to the other and parse received messages on both and check if the message comes from the other side by checking the sender number than parse the data in the message as needed.
Differently if you go over GPRS or Data Transfer and you are on the Internet then the desktop could host a web service in IIS for example so the Phone can directly connect to such web service and call a method passing the data required to be transferred.
in fact you only need the phone to know the IP address of your server or desktop and to connect and consume the web service via the Internet when data connection is available and if not you can send a SMS to the desktop' SIM card.

why cant I see UDP traffic generated by c# application in wireshark?

I am using the UDPClient class to send and receive messages on my loopback address. The executables are also interacting with each other. But why doesnt the traffic appear in wireshark?
BTW I am running windows inside parallels on OSX and can select only 1 interface that is my intel pro net network card in wireshark.
Here's the key phrase:
on my loopback address
The loopback address is a complete additional interface, not just an address. Wireshark is configured to listen on a specific interface, and I'm guessing the loopback interface is not it.
The loopback traffic is not captured by the Net Packet Filter driver.
One workaround is to send it to the IP address of your Intel Pro NIC. In my experience, this is enough to hit the NPF capture driver and show up in Wireshark. (Well, to be accurate, my experience in that matter doesn't involve a VM so YMMV).
Of course, the listener should be bound to that NIC IP to receive the packets (and not only to localhost).

Categories