How to find all the available MIDI ports over network using CoreMIDI? - swift

I am working on an app which needs to send Midi over wifi. I looked at CoreMIDI and the MIDINetworkSession class. I have set the default session's policy to .anyone and also enabled it. But I am not clear what to do next. I looked at PGMidi but it didn't list out the remote host's MIDI ports after making changes to the session.
What I want is a list of all the MIDI ports that I can connect to on the remote machine running MacOSX.
Is it even possible? Can someone please give me some hints?

I was able to figure it out. Here is what I did:
Scanning the remote service
Suppose my mac is running a MIDI session which is advertised over Bonjour. I used NetServiceBrowser to scan the local network and find out which server supports "_apple-midi._udp" service. Look at the documentation.. NetServiceBrowserDelegate receives a service in the delegate callbacks. Please note that the service object is not yet resolved against the DNS and therefore doesn't contain IP address of the host.
The next step is to resolve the service by using a NetServiceDelegate. The service object passed in the success delegate callback contains everything that is there to know about that service. So now, you have a list of IP addresses/hostnames and corresponding port numbers.
Sending MIDI
Create a MIDINetworkConnection instance using the ip address/hostname and the port number. It looks like a synchronous call, so may be it doesn't contact the server itself. Next, get all the midi devices and iterate over Entities and Destinations. Its given in this document

Related

How to find IP addresses of devices on local network which are running an instance of my app in Swift?

I'm working on a simple Swift app where one user can find other machines on a local network which are running an instance of my app and then send data to that machine using TCP sockets.
My question is how to find IP addresses of devices on same network which are running an instance of my app (cross-platform)?
I was thinking about listing all devices on local network and then
checking whether they have opened specific port (the port my app is
using)?
I also found that Apple provides service called Bonjour which could make my process discoverable. I'm not sure if this solution is good for cross-platform communication.
Apart of Mac-related stuff and high-level solutions (I believe keywords "network service discovery" will bring you to them), there are a couple of things that will work for a local network:
I Have a server that clients should report to. Some short hello-like UDP message and a timeout mechanism will be sufficient to keep a list of available clients in the network.
II Use IP or UDP multicast groups to notify others that a client has just connected to the network. Send a message to a multicast group and listen to this group to build a list of clients.
However, broadcasts and multicasts won't be transmitted through a router. So if your network is large enough only neighbouring clients will hear your notification. In order to overcome it,
III DHCP servers can be configured to provide custom data to clients via unassigned DHCP options. Large networks have usually such server. You probably can use it to send out a list of clients, but I'm not sure about this.

gwan. Accessing site through external IP

I have a Gwan server set up at home on my Arch Linux box. I'm running "motion". I have a router that, of course, handles my external IP address.
I want to access the avi movie shorts generated by motion through port 1000 which is port forwarded through my router to the box on my internal network. I've written an event_end script that copies these motion videos to my Gwan "Document Root". I've set the particular directory up according to the Gwan docs and can see these videos using the external ip address:1000 just fine when I'm at home. But when I click on the very same link from the machine at my office, I get this error message in Firefox: "Firefox can't establish a connection to the server at 99.99.99.99:1000.".
So I don't understand why I can see that link when I'm at home but not from anyplace else. What setting have I missed?
Thanks.
Are you sure that your firewall at work allows traffic on port :1000 at all?
port 1000 which is port forwarded through my router to the box on my internal network [at home]... but I get an error "Firefox can't establish a connection to the server at 99.99.99.99:1000" [from my office].
As Pete noticed, this sounds like a routing error.
As the HTTP client, Firefox, cannot even establish a connection, the problem happens before G-WAN can do anything.
while I was using quickserve, I could view those videos just fine while using port:1000
...probably from your private network at home, and not from your office.
If quickserve was available from your office then, since then, you have messed with the router port mapping OR with the G-WAN listener (hence the connection failure).
Unfortunately, since G-WAN won't receive anything until you get this right, its log files won't help.
And as you do not provide any information about your port mapping and G-WAN listener, we can't help you to spot obvious errors.
Note that this issue is a system configuration problem and has little to do with the G-WAN application server itself (remember that Stackoverflow is a Q&A site for developers). The Serverfault site might be a better place to discuss your problem.

JmDNS : Discover the same service on Multiple devices

I am trying to use JmDNS to discover the services.
I am able to discover the service using the Sample Code given at the
When I add a service listener and invoke the addServiceListener, it properly identifies the service.
But, I have the same service running on more than one device. Now, I am wondering how I will be able to get the list of all the IP Address on which the service is running. I am only able to get the IP Address of one the devices.
And also what is the difference between JmDNS and JmmDNS?
See at the docs to learn what JmmDNS is: http://jmdns.sourceforge.net/apidocs/javax/jmdns/JmmDNS.html
To get all IP Addresses where the service is provided, you just need to add one listener for the service. It should be notified for every service available in the network.
So the method serviceAdded(ServiceEvent event) from the ServiceListener will be called multiple times. But you have to trigger that the service will be resolved and you have to actually save all IP addresses yourself.

How to connect and read/write file to a local computer on iphone?

i have a problem with local network connection. i'm writing an iphone application and i need to read/write files to a computer. Both devices connected on the same network.
if it's possible, i want to get connected computers ip list, select one of them and read/write files like pdf, doc, txt etc.. if it's not possible to do, i will write the computer ip which i want to connect. There is no problem, both of solution is OK.
But i dont know what do i do after get the computer's ip ?
i found this chat client/server on local, but i got it very complicated.
Anyone have any idea about this ?
You'll need to have a server running on the computer, which can show files and allow for files to be read and created.
Easiest is to run a webdav service on the computer, Apache provides the mod_dav module for this purpose.
The iPhone app then becomes the client. I'd suggest using neon for this purpose. It's a C library that provides listing, reading and writing files on a remote webdav server.
That's how I would do it.
1) Find the network address of the computer you want to connect to. For this you can make use of Bonjour. It's very easy to setup because Bonjour handles the resolving of address for you.
You just have to publish a service (e.g. _myprotocol._tcp) via the ´NSNetService` class which is available on iOS and OS X (Windows too)- in your case you would publish the service on your computer.
Then you search for the service with the NSNetServiceBrowser class.
When you found a service you can then resolve it. This actually gives you the network name of the other device.
2) Connect to the other device via a tcp socket. The CocoaAsyncSocket library is very good at this. This project also includes some examples. One example already provides a bonjour server and client implementation.
i found exactly what i want. The solution is here

Get Azure public IP address from deployed app

I'm implementing the PASV mode in a FTP server, and I send to the client the IP address and port of the data end point. This is stupid because the IP is actually where the client is already connecting, so there ire two options:
How could I get the public IP
address from a given instance? Not
the VIP, but the public one.
How could I get the original target
IP address that the user used from
a Socket object? Considering routers and load balancers in the middle :P
An answer to any of this questions would do, although there is another way that could work... may I get the public IP address doing a DNS look up of myapp.cloudapp.net?
A fourth option would be use the Azure Management API library... but, too much trouble :P.
Cheers.
Not sure if you ever figured this out, but here's my take on it. The individual role instances are all behind the Windows Azure load balancer and have no idea what the original, outward-facing IP address is. Also, there's no Management API call that returns IP address - Get Deployment returns the URL but not the IP address. I think the only option is going to be a dns lookup.
Having said that: I don't think you can host a passive ftp server in your role instance (at least not elegantly). You may open up to 25 input endpoints on your role (up from 5 - see my recent blog post about this update), but there's manual work involved in the configuration. I don't know if your ftp application lets you limit your port range to such a small number of ports. Also:
You'd have to define each port as its own input endpoint (this is the manual labor part I mentioned) - input endpoints don't allow a port range to be specified, unlike the internal endpoints.
You'd have to specify the port number that's used internally, and the port numbers would need to be sequential
One last thing on ftp: you should be able to host an sftp server with no trouble, since all traffic comes through one port.
The hack that I'm contemplating right now is to retrieve http://www.icanhazip.com/. It isn't elegant and is subject to the availability of that service, but it gets the job done. A better solution would be appreciated!