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
Related
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.
So I want to create a Multi-Client/Server application. I know multiple clients can connect through one port, and I want to allow for the messages to be stored in a list when the server is "offline".
I'm having trouble finding information online to help me understand how the server can tell the difference between the multiple clients on the port. For example, if a 2 clients send messages to the server while it is offline and I store them in a list, how would I be able to tell the server that this message came from this client first so answer that, and then this message came from this client next?
Is there any information online on an easy way to achieve this? Any help would be greatly appreciated.
Sorry, I didn't make it very clear. I'll try again! Ok basically I want like a middleware between them so that the clients contact the middleware with the message, the middleware checks if the server is online and if so it sends it on, otherwise it will store the message(s) until the server is connected again. Does this make more sense? I'm not great at explaining myself, sorry again!
There seems to be some confusion of concepts here. When client are not connected they obviously can't send anything to the server and also don't have a port. Conversely, when the server is running and clients connect to it, the server has an object for each connection, representing each client.
I am new to C# Socket programming. I am trying to build a simplistic application that can detect when a client application connects to the server application.
When connected, I want to send 1 piece of information to the server and receive 1 response back (confirmation).
Afterwards, I just want to know when the connection is broke. Within my application, I do not have to know instantly when the connection is broken, just within the timeout if fine.
Can someone please help me understand what I need to do to accomplish this. Sample source code would be nice, again I am a novice programmer and this topic is way above my head.
I would need help with the client app and server app.
Thanks in advance!
Jorel
I would not begin with sockets if I were a novice programmer. It's not an easy subject to start with, and you need to know more than just how to send a piece of information. You need to know how the protocols work too and how do deal with their way of send/receiving information.
I would recommend you to use wcf instead, since WCF takes care of all lower level details for you. You will just need to know how to send and receive information.
Currently I'm tring an telnet client sample written by C# to connet a data acquisition unit, I could connect the server and send the commands, but I always received the same data (I cound't post images, the data is{255,253,3,255,254,1,255251,1}). I also do some research, seems this problem is related telnet protocol/negotiation, but I don’t have any more idea and experience on that what should I do, could anyboday please help to look at it? any suggestion & solution is appreciated.
others, I could directly use the telnet of OS to execute related commands to see the correct data.
If you don't need to display anything in a terminal window, respond to DO & WILL with WON'T to all offers. Replace 253/254 with 252 and send back to server. There maybe more negotiation from the server. Respond again as described above. After negotiation, log-in & password should follow, unless authentication is disabled. A successful log-in will follow copywright and other info till the user-prompt arrives. Now you are able to send OS-commands and process the response you get.
I'm tyring to add a feature to my app that sends a nudge to all users of my program (family members inside the house), and when they receive the nudge the window of my app on their computer shakes for a second...
Can somebody please suggest how i'd have to go about this? I've never worked with tcp/ip before.. Is this what I should use, or is there something better?
I have tried to come up with my own solution however none of the samples ever work. So I thought maybe the people on SO might know of other ways?
Thank you :)
If this is just an "in-house" (pardon the pun) application, and you're all on the same network, you might consider sending a UDP broadcast packet. Each instance of your application could listen for a packet on a particular port, and when the correct one is received do the window shake thing.
You might consider UDP for this. Since you can broadcast/multicast via UDP it may be more suitable for this sort of application. There are downsides - UDP transmission is not reliable or guaranteed in the same way as TCP.
I'd go with a good XMPP Library. Maybe Jabber-Net?
You'll also have the added bonus of being able to connect to Google Chat and now Facebook chat later.
You haven't specified if presence in your case requires a server or not. If it is client/server oriented, using XMPP gives you the server side for "free" as a bonus.