Unique Network Need: Unity Listens on Port as a server for data from 3rd party app

The Unity app we are writing is something we want to be able to query via an external non-unity app. We want to be able to send requests to our Unity app and have it return to us rendered images based on the input we send it.

I’ve searched and searched but it seems that all the code I can find is about Unity getting data from other systems, but not about another system sending a request to a Unity app.

I figured we would set up 10 or so threads that were listening on a given port to handle simultaneous requests coming in, and then return the data as needed

Does anyone have a tip or suggestion on where to get started?

If your planning to do this in the webplayer, it won’t work.
As a standalone app it will and you could use the Lidgren Network library for it.

You can also use a web server to facilitate - so your unity app opens a WWW connection to the server, and the server tells it whether a screenshot has been requested. If one has been requested, open another WWW connection to upload it. Then your non-unity app talks directly to the web server, logging a screenshot request and picking up the result.

For bonus points, the server never gives a negative reply - it just sits on the query connection until a screenshot is requested or a timeout is reached. This reduces the workload at both ends of the connection - look up Comet.

Thanks for both suggestions. They are both possible solutions. I will look at the lidgren library first. I also found this link to a simple server unifycommunity.com

That code sample is currently only setup to receive. The sending part is not fully implemented. So if lidgren already has all that working I will go that route.

Thanks again for both ideas.