Android as host not working, Unity LLAPI - c#

so i'll try my best to post this properly. I asked this before on unity forums, but i didn't found an answer yet, here is the link if you want it.
I have a working demo of a Server side broadcasting and Client reciving the message parsing and using the info to connect to the server.
NetworkTransport.Init();
NetworkTransport.AddHost(defaultTopology, PORT)
NetworkTransport.StartBroadcastDiscovery(id,broadcastport,..,..)
NetworkTransport.Receive(..,..)
NetworkTransport.Connect(..,..)
etc. I can go on further detail on code if you want it, but as far as its working on PC fine I think the code is fine.
When I try the same with PC as server, Android as Client, if the Android device act as a client, he don't recieve the broadcast from the server but i can connect manually(i know the IP of my local machine) and i can send and recieve messages.(This is okay except for the broadcast problem that would be nice to fix)
If the Android act as Server and PC client, the PC recieves the broadcast but can't connect to the Android neither automatically nor manually.
I tested with 2 Androids an the results are bad too.
The client didn't recieve the broadcast and if I try the manual connection the server didn't recieve the connect event. The main goal is using 2 androids.
I searched for problems with the Network and Unity but i only found some people talking about the Android Manifest but not saying exactly what to do about. If you can point me to the correct direction with this i would apreciate.
Also maybe the Android 6 permissions have something to do with that?
I personally think that the android cant recieve nothing until is conected, so when he acts as Client he don't recieve the broadcast but can connect and then works fine, but as a Server he cant recieve the connection.
Maybe has something to do on Android Ports? I usually use 25001.
Using Unity 5.3.5f1
Thanks and sorry for my poor english.
Edit:
I changed to Unity 5.4 to check about Android 6 permisions and isn't working too.
You have a demo here if you want to try
Is an isolation from another project so maybe you find comented delegates and other stuff.

Yes, it is indeed the Android Manifest. I see no other reason why this is not working. The method permission query is handled changed on Android 6.0. You have to download Unity 5.4 to fix this problem.

Related

Connecting C# application to iOS device via lightning cable

I haven't been able to find any resources regarding this, so I thought I'd ask here.
I have an iOS app that I am developing, as well as a C# desktop app. I'm currently able to connect the two by creating a Socket Server on the desktop app, and connecting from the iOS app. This works well, but I'd like to do this without requiring the devices being on the same network. Communicating via Usb (lightning port) seems like the logical choice, but I can't find any resources at all about how to do this. Are there any tools or best practices regarding this, or is this even possible?
Thanks!
Peertalk, an open source library allowing to pass TCP connections through the USB connection without being part of the MFI program. PeerTalk uses the iTunes usbmux system to relay TCP connections across the iOS USB connection.
I wasn't able to use Peertalk, since I'm using Xamarin for my project. However, I spent the last week researching and documenting what I learned, and I posted it as a blog post here
http://thecodewash.blogspot.com/2017/05/communicating-with-your-ios-app-over.html
Hopefully this helps others.

Cannot connect to WebSocket Server. No idea why

I'm using the code from this article just to try and get something up and running. However, I cannot seem to connect to the web sockets server once it's running.
I have tried forwarding both ports 8080 and 8181, ensuring that they are forwarded using canyouseeme, allowing the ports under my firewall, completely disabling my firewall, trying and forwarding different ports, etc.
Nothing has worked so far. Both the HTML browser page and console server application run just fine with no errors but I keep getting this error message when I try to connect through the HTML page in my browser:
Connecting to ws://localhost:8181/chat ...
Socket closed!
I have never used WebSockets before so I'm not sure if I'm missing something like if I need to install some framework, run some daemon, or what. I'm running Windows 7 64 Bit and using Visual Studio to run the solution. Not sure how to get this to work. Anyone have any ideas?
The server mentioned in that article is likely using the older Hixie protocol. If you are running a recent version of Chrome or Firefox then you are using the newer HyBi/IETF protocol. The article was written in Jun 2010 before the newer protocol was standardized and adopted.
Update:
Fleck looks like a descendant of the code in that article (via Nugget) that supports the old and new protocol variants.

Connecting to C# Server from iOS

I am trying to make an iOS apps which connects to a C# server (using TCP) programmed similarly to that shown here. On the client (iOS) side, I use CFStreams and the CFStreamCreatePairWithSocketToHost method to connect to my cloud server. I have followed the tutorial found here precisely for the iOS side. A copy of the main connection program can be found here.
Unfortunately, when I run the app, I never get a NSStreamEventHasBytesAvailable event from the inputStream, even though the server is programmed to send a message to the client immediately after the connection has been made. Can someone help me fix this?
All help is greatly appreciated, and I always accept at least one answer!
You may want to print out on the server side what was received and what was sent. And you may want to read this, as he does a good job of giving ideas of how to get more info:
bytesWritten, but other device never receives NSStreamEventHasBytesAvailable event

Is it possible to have Async Socket in Mono for Android using C#?

I just started developing a sample application for Mono. The main task is to implement a tcp-socket server on the android tablet listening for connections from a client. after connecting the client starts sending real-time data and the android application displays the data on the screen. this is important to implement the server side on the android. I am using Mono for Android / C# . I already have about a week google searching and sample browsing.
My question is: if the Async TCP socket works on the android mono framework or not. because my code works fine when I use it in "windows application" to "windows application" platform. but when I change it to "windows application" to "android" the connection simply disconnects.
I know the question is wage, I know you all expect sample source... If I had a place to put the sample, I would definitely put it!
I am using Mono for Android Api 12 Emulator
I already forwarded the TCP port using emulator telnet console 'redir' command
connection establishes but data does not being received on the server (android side)
any help/sample/guide will be appreciated
It is possible to have Async Socket in Android using Mono. there is no specific difference with windows application for this scenario. my problem was actually from de-serializing the message which caused the connection to stop.
problem solved by adding new DesrializationBinder and changing AssemblyName for Android namespace.

Socket failure detection

I'm interested to know how can I detect (at the server side ) that a socket connection failed when the client computer has the network cable plugged out or is hard reseted. This would be useful for a client server project in c#.
Currently I'm able to detect socket exceptions only when client closes the application and implicitly the socket.
Googling a bit I found abou the FD_CLOSE IEvent of WSAAsyncSelect . Would this work for the cases that I've described above ?
Take a look at this answer: Instantly detect client disconnection from server socket
UPDATE
Ok, i figured out what you are talking about. There is no way you can find out on the server if client cable is unplugged or something happens to it's network. You will simply not get any response from that client any more. Only way i can see is provided in link at beginning of this answer.
There is WSAEventSelect native method inside of Ws2_32.dll (Winsock2), but it's only used to detect network unavailability reason on local machine (where app runs).
I took a look inside System.Net.NetworkInformation.NetworkChange class source code and there you can see that everything related to WSAEventSelect is about local machine (in your case server).

Categories

Resources