I'm doing one university homework, where I need to make the Chinese Checkers game work via sockets.
I've followed this tutorial on raywenderlich and it seems easy setting up the streams, but in this tutorial its used a local server to intermediate the connection, and I don't know how to make a server, so I kinda need to make the connection be p2p, but i don't know how I'm going to discover the IP and Port the app is running on iOS.
Personally, it's the first time I've seen about sockets and I really need help.
If you guys can teach me how to connect 2 apps to each other directly USING SOCKETS (otherwise my teacher won't accept it) or point me where I can learn how to make a simple server for this matter it would be really great.
P.S: I know I can use GameKit, MultipeerConnectivity and etc for it, but I'm really obligated to use sockets :/
Related
I was thinking about a project the other day and an idea stumbled across my mind:
How would you set up a server, for instance at a restaurant, and have an app of the restaurant chain which finds and directly connects to the locally running server without being in the same network. This should work at higher ranges, so simple Bluetooth is not fitting here.
I've done some research, but I'm not very... good with protocols, and nothing I've found seems to really fit that goal. So I'm wondering what the best way to code this connection would be. Any ideas would be helpful :)
Here are the requirements:
A standard phone should be able to perform the operation.
It should have a fairly high range, think a big store or restaurant.
Server and device do not have to be in the same network.
The connection get's established by the phone on app start, to a server that can do whatever it needs to get this done.
I have an iOS App where people can post something to their wall. Now I would like to make a function that, when a client posts something, everyone who is online (application active state) can see a message that tells them that someone just posted something.
I have been using Sinch.com, Quickblox.com etc.
Sinch is bad, delay and slow, and it cannot send messages to over 10 clients. And it's for chatting, not for notification.
Quickblox is good, but it has a really high price and it's for chatting too.
I have tried to use PushRemoteNotification, but this depends on whether users turn on notification permission or not. Even if they enable notification, it is really slow when I send a message to over 500 clients through Push, and also I don't know which devices are online, so I believe this is not a solution.
I am planning to use PHP Ratchet WebSocket server and use one of these WebSocket libraries for my app Objective-C SocketRocket client or JetFire, but this is just my plan. So do you think it's possible for a huge amount of online clients?
If there is anyone who has any better idea please help.
I'm not entirely sure what exactly you are looking for, but I've had a lot of success using Twisted, which is built on top of Python. It has good functionality for building socket connections that allow pushing data from the server to clients. Ray Wenderlich's site has a great tutorial on Twisted (and specifically using Twisted with an iOS app) that helped me quite a lot.
Alternatively, socket.io, which is built on top of node.js would probably suit your needs quite well.
Can anyone point me to an example or an explanation of how to get a server going on an iPad? I want to use TCP sockets and I've already downloaded the current AsyncSocket stuff but it's trickier looking than I thought. I've been researching but everyone talks about iOS as the client and some PC as the server. I would like to set up my iPad as a local server for a game I'm writing.
You can use the C socket api. Every valid C standard library is also valid in Objective-C. Here is a nice guide for programming sockets with C.
my Task is to send the G-Sensor Data nearly in realtime from an iOS Device to an Application running on a different Device (OSX, iOS, maybe Windows). From all I've read so far, a Socketstream seems to be the best choice for this kind of Task. Do you agree?
My Question is, since I have no experience in Socket programming, are there any third party Frameworks that make socket programming more easier? Maybe that they already created something that will reconnect after the connection was lost and such things like Error Handling? I guess that not everyone invents the wheel again while programming with sockets?
Thank you for any kind of information regarding this topic.
twickl
I would strongly consider CocoaAsyncSocket. It has very much all the callbacks you will need. There are also a version for Tcp and UDP as well.
What would be the best way of sending a signal from an iPad to an Arduino?
I am trying to use XBee, with iPad and Arduino to send a wireless signal.
I want to make a big red virtual button on an iPad that, when pressed, turns on an LED on the Arduino.
I am a total newbie when it comes to iOS, but OK with Arduino and XBee.
So I'm not sure if I understood correctly, but in my meaning there is only one simple way to solve the problem:
Connect an XBee to a Computer and another to the Arduino. On the computer you launch a webserver, which will be accesible from the iPad over Safari. This server handles the clickes and writes to the XBee Com Port, for communication.
Here are some examples, people already made:
http://www.projectallusion.com/1/post/2009/11/iphone-controlled-solar-powered-arduino-tank.html
http://www.sparkfun.com/tutorials/152 (not with xbee, but you can implement that by yourself)
I know it's been a while but I just came across to this question and yesterday I was doing the exact same thing so I'll share the method I used and the source of it.
In order to set a LED on or off in an Arduino board from the iPad you really don't need anything more than a browser. This is of course if you have a way to connect that Arduino to the local network.
Today you have at least two options. The WiFi and the Ethernet shields. Once you have your Arduino board inside the network you can send the instructions (HIGH or LOW) to the board form the browser.
These are my two boards connected waiting to be plugged to the local network:
Of course, you'll have to code the board to process those instructions. There are many examples on how to configure network settings and state instructions:
If you have a bit of time and want to do something more elaborated you could create a simple app to graphically control the state of those LED(s).
Inside you'll basically do the same thing, create the URL command and send it to the Arduino IP but it'd look much nicer. If you integrate later more controls the sky in the limit.
My experiment is a combination of what I learned from this nice tutorial and some tips I've read here and there.
I hope it becomes also useful to someone else.
Cheers,
Since you need to use a network connection from the iPad, a possibly simpler way to do this would be to use a WiFi module on the Arduino to poll a web script, and have the iPad write a state (button press) to that web script.
There's a handy WiFi module called the RN-XV that's designed like an XBee. I wrote up two tutorials on it:
http://log.liminastudio.com/programming/getting-started-with-the-rn-xv-wifi-module-node-js
http://log.liminastudio.com/itp/physical-computing/using-the-rn-xv-wifi-module-as-a-remote-switch