Raw sockets on NaCl? - sockets

Right now I'm trying to migrate a code written in C to a application for Chrome browser.
I'm new in programming on the NaCl for Chrome Apps and I don't get really good if with the native client I can use the raw sockets. I need to use the raw sockets because I must create modified packets such as UDP with TTL very low.
So in general my question is, Can I use raw sockets (C style) with the NaCl? If the answer is yes, If you could provide some extra information, It would be great.

You can use TCP and UDP sockets, via the nacl_io library. Look at the nacl_io demo in the Native Client SDK. It can be found in the subdirectory examples/demo/nacl_io_demo.
Please note that these sockets APIs are only allowed when running as a Chrome App, not on the open web.

Related

How can I build/install/run a server program to communicate with the iPhone?

I'd like to play with the idea of creating a server program that communicates with an iPhone app over socket connections. I've found several guides within Apple's documentation for client side programming (with CFNetwork, NSStream, etc) but I don't know where to begin on programming the server application, or even what language to use, or for that matter, how to deploy and run a server application on my current web hosting package through Go Daddy. A simple instant messenger style application example should get me started, but any advice is appreciated.
if you want to create socket connection is better to use CFNetwork , it has more flexibility for you I already used NSURLConnection but CFNetwork has better performance. this is my steps and how I developed my app :
configuration of server
selection C++ for my server side (service)
start to develop a client-side app for iphone to connect to server using NS classes
but I had some problems in sending and receiving message to and form server . so I changed it to CF classes it works better and faster now.
The easiest way to handle server-to-device communications is to use APNS (Apple Push Notification Services).
Communication in the other direction (device-to-server) can be handled simply with NSUrlConnection.
If you want to write your own socket code for this, well - good luck with that.
Do you want your client application to be able to run on more than one OS? If so, you might want to stay clear of anything Apple specific. Although, if you strictly want to run on iOS, using MusiGenesis' suggestion could save you a ton of time.
I have found that Python and Perl are both pretty great for socket programming. I know that Python has several libraries built in for handling HTTP requests etc. If you want to run your server as a daemon, I found this code very helpful:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
Here is a general python sockets guide:
http://docs.python.org/howto/sockets.html
Good luck.

Raw sockets permission IPhone?

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.

Objective-c iphone programming with cisco routers?

I've seen some apps that connect to routers via ssh.
Can anyone recommend any documentation on interacting with Cisco IOS configs and notifications? I'd love to write some custom in-house code!
Most of the configuring/querying can be done via SNMP, so you don't have to have a SSH client/command parser built in you application. What's supported depends on router/ios version. You can check here: SNMP OID Browser. SNMP can sometimes be overwhelming, but in time it can be of great use to you. My first suggestion is to find a SNMP browser (eg. from solarwinds) so you can inspect what info you can get from the router. Then you can use NET-SNMP library to do the actual querying/configuring of the router, or if you are willing to pay you can try IP*Works.

How do you communicate to a Modbus device within an iPhone application?

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

Sending information over sockets to an iPhone MobileSubstrate extension hooked into MobileMail/MobileSafari/MobileMaps

I am trying to use MobileSubstrate to have a socket listening on a port on various UIKit applications. However, when my extension hooks into MobileSafari, MobileMail or MobileMaps, it is unable to successfully create the socket. I found this page on the iPhone Dev Wiki which clarifies the issue: http://iphonedevwiki.net/index.php/Seatbelt .
Is there any way around this for the built in applications to be able to listen on a socket (or open one at all?) If not, what's another good (and easy) way to do interprocess communication on iOS?
Personally for inter-device communication, i use CFMessagePorts which are a lot like mach ports.
http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFMessagePortRef/Reference/reference.html
If all you need is notifications - no data, then i'd suggest looking at the Darwin Notification Center (based off of CFNotificationCenter)