I want to broadcast some data bytes in particular wifi range through my iPhone app...so that every receiver in that particular range will receive that bytes. I am very much new to this concept.
Is there any sample app?
Thanks in advance...
This class is very interesting for doing socket in Objective-c, either UDP or TCP : http://code.google.com/p/cocoaasyncsocket/
Just send UDP packets to for instance address 224.1.2.3 which is a multicast address. I am not 100% sure where it will go, but if you disable 3G, at least then it should go to WiFi.
Related
I developed a C++ app to stream video from a webcam on an Odroid device over UDP. The client is an iPhone app using simple UDP sockets and it works perfectly over Wi-fi, but not over LTE. The sendto() call works okay, but the recvfrom() blocks forever. First I thought it has to do with iPhone blocking UDP traffic, but I also tried a client on my laptop connected in the iPhone's hotspot and thus over LTE.
Do you think there is something with phone providers blocking UDP traffic?
I preferred UDP instead of TCP for faster streaming.
Any advice would be highly appreciated!
Thanks!
UPDATE: I found the cause of the problem after some further inspection. It turns out that UDP over LTE sets the IP_MTU_DISCOVER flag and if the user's packet is larger than the device's MTU, it does not perform IP fragmentation but simply drops the packet. My application is sending packets larger than MTU, but in the case of Wi-fi they are fragmented in the IP layer. If you disable the IP_MTU_DISCOVER flag, the large packet is fragmented and arrives successfully in the destination. The other alternative would be to send packets smaller than MTU from the application. Both approaches do not perform that well, but at least the mystery is solved.
I am new to socket programming and don't have much idea on how it works, Here is the use case, Im developing an iPhone app, where users stream real time audio originated from another iPhone device (in short Multi casting)
What I have done so far:
I opened a port on server which keep listening to incoming data from clients. On the iOS side, i implemented methods thats read the packets received on the server and process it accordingly (i have used GCDAsyncSocket)
Problem where I need help:
The above use case works perfect for 2 users, one that sends the audio data to the server and the other one reads that data to play audio. But actually there would not always be a single user originating audio data, they could be more than 100+, Now when all of them are sending different audio data to server how could i filter data for the listeners that everyone receive only there data, I overcome this problem adding a token on every packet like
unique_token:<ffdefa09 fedead3...... //Audio Data
But this process is way too slow as every client is listening all the packets and only process the ones with the token they are assigned.
Is there anyway, we can make a peer to peer connection by which the originating device become server and only sends data to its listeners and don't bother anyone else?
Can't you add something like a light protocol before you start steaming audio data to server ?
iPhone -> server [Request: Start Stream Audio]
server -> iPhone [OK: TCP Port:4444]
// iphone sending audio packets to port 4444
iPhone2 -> server [Request: Start Stream Audio]
server -> iPhone2 [OK: TCP Port:4445]
then the server can filter all audio channels with TCP port ID instead of packet ID (or maybe I misunderstood your issue)
Btw I don't think you can do any "real" P2P with iPhone on cellular networks because of providers firewalls
for every end who send the audio data, you create a socket and recv audio data, and for every end who receive the audio data, you create a socket and send audio data.
P2P is lots of work , because many device are behind the public address.
You need to separate your command data from your streaming/audio data.
First you need the iphones to tell the server what they want,
iphone 1: "i want to stream this data with id 1"
iphone 2: "i want to listen to stream with id 1"
that way the server can tell the iphone where to connect for getting the data it needs, as HaneTV suggested with port numbers
I am building an Arduino based servo driver that I want to control with OSC commands from my iPad over the Internet.
Is it possible to send OSC commands over 3G / UMTS with my iPad or iPhone to control a device? So I will not be limited by the router's range when I send OSC commands to the controller when both devices are part of the same Wi-Fi network.
It seems that the applications I downloaded (TouchOSC, iOSC) can only send OSC data over Wi-Fi, however I'd like to send the commands over the Internet (with port forwarding settings in my router).
I would get one of these. Look ma, no wi-fi :)
OSC typically uses UDP (User Datagram Protocol), even if some newer OSC implementations also allow TCP/IP messaging (also see Difference between TCP and UDP?).
Unfortunately (as far as I know), UDP does not work over 3G, which seems to be your problem. In other words: two mobile devices cannot talk to each other on a cellular network. So it has nothing to do with OSC apps not being able to do this, it's just not available from the cellular network.
However (I think, not tested), I see two workarounds here:
try to use TCP/IP instead of UDP to send your OSC packets
if you need UDP on the Arduino side, you could use a server in-between
Do port forwarding on your router to forward port x to the Arduino, and then use the IP address from whatsmyip.com and use that one in the touchOSC app when inputting the IP address. That may work.
I need to send and get packets via UDP and TCP in iPhones and the server. But, I figured that if I wanna send packets to a client (iPhone), he is... A kinda server.
So, let's say I'm sending and getting packets to iPhone via the port 2347. Do I need to open the port on the iPhone or something like that? Is there any Firewall built-in to the iPhone?
No firewall on the iPhone. However, 99% of the time, the phone will not have a publicly accessible IP. It may be on wifi behind a router, or it may be on the cellular network most probably behind a NAT pool. Either way, you don't have access to any of those pieces of equipment, nor do your users in the cellular context (and potentially some cases of wifi usage). Think about doing this another way.
There is no firewall on the iPhone by default. Provided you don't need the iPhone to act as a server, i.e., bind a port, you can have the server send packets back to the iPhone using the information in which they were received, i.e., IP and port, using the protocol of your choosing, e.g., TCP or UDP.
Has anyone tried to do a tcp client server app using the emulator using the pc as a server and the phone as the client?
I've got a bit of an issue where its only sending one packet, ie 1491 bytes of data regardless of how much there actually is to send, from the client(Phone) to the server(PC)
Thanks
James
1491 looks like it's related to the MTU (the maximum packet size supported by a protocol). The ethernet MTU is 1500.