Is it possible to send tcp request using NSURLRequest/NSURLConnection to an ip address and associated port from an iphone app, if yes than how?
Using NSStream it is possible to establish tcp connection to an ip and port. I am trying to establish connection to a non apple device and using nsstream it works fine but it is not very responsive [may be due to the remote device] so I am looking for NSURLRequest/NSURLResponse way of doing the same thing. Can anybody suggest how to do this [if possible]?
A little googling leads me to this link
http://lukassen.wordpress.com/2010/0...-on-iphone-os/
Is it a reason behind my problem with NSStream though I do not get any error
Thanks
Arnieterm
No, it is not possible.
CFStream and/or NSStream are the only way to do it, eg:
http://dev.im.ethz.ch/wiki/Socket_communication_on_the_iPhone
or a wrapper around them:
http://code.google.com/p/cocoaasyncsocket/
Related
I'm working on my multiplayer game for wp7.
At this moment i successfully implemented the multiplayer game on Udp on UdpMultiCastClient.
Well, without the phone itself i cannot test it, but from other various site(SO included) it seems UDP packet won't cross over outside of the router. So I wanted to implement a TCP P2P, so each game client connects to everyone else, so data wont be proxied through server.
But the socket class on WP7 doesn't have Listen method, neither AcceptAsync.
Is it normal?
It unfortunately seems like you can't bind a WP7.5 socket to listen for incoming connection on a specific port. So the phone can't act as a server. This is really a shame. TCP P2P connections would be awesome.
Hopefully this will be implemented into next version of Windows Phone. Meanwhile the easiest solution is probably to use a server in the middle which both devices connect to.
Edit:
Socket Listeners is available in WP8.1 ...
https://msdn.microsoft.com/en-us/library/windows/apps/hh202858(v=vs.105).aspx
https://msdn.microsoft.com/en-us/library/windows/apps/hh202874(v=vs.105).aspx
I'm updating one voip application and one of my issue is supporting multitasking.
I don't know how I should manage multitasking. Specially I need define connection as VoIP, to receiving incoming call when app is in background, but I don't know how do that.
I searched and found This tutorial and a lot of other pages, but I could not found how those work.
Is any one able to explain me it?
Apple only allows you to set up a TCP connection that you can handle with a CFNetworkStream. You need to bind the socket to a CFNetworkStream and then set the handler to the kCFNetworkStream value that enables VoIP. You'll need to support TCP to handle the socket as Apple doesn't support backgrounding over UDP. The documentation provided by Apple is quite clear on what you can do.
I'm discovering capability of Iphone network programing. I have already working ICMP ECHO REQUEST / REPLAY using SOCK_DGRAM. And I would like to do more stuffs. For example port scan in NMap. Yes, I can use TCP connect(). But I wanna try to send TCP SYN.
My question is, can use raw sockets ? Because Iphone doesn't have root permission. And Unix Os need permission to use raw socket. But I found somewhere, that I can use SOCK_RAW and build own IP Header. Allows this Apple ?
Thanks for any reply.
You can't do that inside the SDK. If you are building a jailbreak app you can do this without any problem, probably you will need some headers, including the UDP header and possibly some BPF if you want to sniff packets (like tcpdump, which you can find a iPhone version on Saurik's repository) that are not present on the SDK. You can just copy them from Mac OS X (/usr/include) and put them on /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/usr/include/ for example.
I need to send and get packets via UDP and TCP in iPhones and the server. But, I figured that if I wanna send packets to a client (iPhone), he is... A kinda server.
So, let's say I'm sending and getting packets to iPhone via the port 2347. Do I need to open the port on the iPhone or something like that? Is there any Firewall built-in to the iPhone?
No firewall on the iPhone. However, 99% of the time, the phone will not have a publicly accessible IP. It may be on wifi behind a router, or it may be on the cellular network most probably behind a NAT pool. Either way, you don't have access to any of those pieces of equipment, nor do your users in the cellular context (and potentially some cases of wifi usage). Think about doing this another way.
There is no firewall on the iPhone by default. Provided you don't need the iPhone to act as a server, i.e., bind a port, you can have the server send packets back to the iPhone using the information in which they were received, i.e., IP and port, using the protocol of your choosing, e.g., TCP or UDP.
I would like to be able to develop an iPhone application that can communicate with Modbus devices, but I'm not sure how to proceed. Has anyone had experience with this or are there existing libraries out there for this purpose?
You will need first to know how to make a simple TCP client on your iPhone, and a simple TCP server on your computer that your iPhone client will talk to via WiFi. Make sure PING command works and firewall does not block your server port before any client/server experiments, and make sure that server port for experimenting is greater then 1024 and not already used. Then take a look at MODBUS TCP specification from official site, get familiar with function codes you are interested in, and study C code found here. Then make a simple MODBUS TCP client that can send a request to MODBUS TCP server and interprete an answer. The best way is to start reading single register value, then progress in time and add more functions.
I do exactly all above points, my iOS Modbus lib works fine, application is now up on AppStore, PLCLink read and set any modBus data into my Wago home automation.
Installation guide : http://pautex.fr/plclink