Socket Connection on iPhone - iphone

I want to establish socket connection between iphone and a web service that has its own IP address, service name (e.g "_abc._tcp"), and it also contains information about files stored. How can I do this? Can you please help with some sample code or links.
My goal is to develop an application that will get a video file from that server to my iphone and play it.
At first I try to get information of the files but I don't know how to connect to that server and make the video played on my iPhone.
Many thanks in advance

There is a great library for socket programming in objc here CocoaAsyncSocket
Which will help you out a lot. The examples also show how to use NSNetServices to broadcast a Bonjour service.

Related

Socket programming in iphone

I want to send/receice some data to remote machine within network.
I have referred chatty application but it is broadcasting the service but i need to establish one is to one connection.
how can i set sockets for sending and receiving data in iphone?
does any one have any idea? i am new to network programming please help me about this.
Regards,
Sanket
If you want to learn about CFNetwork, then I recommend: Zdziarski's iPhone SDK Application Development - Chapter 7
There are complete explanation of sockets ;)

upload file into iphone app via ftp

I wish upload a file into my iphone app via ftp ( wifi connection on iphone) like some program as airsharing or iFiles..
which are the first steps to do this??
thanks in advance
The iPhone SDK does not have a built-in FTP server, so you will have to implement a simple FTP server yourself.
First, get an overview of the FTP protocol on Wikipedia. Read the actual RFCs, which document the protocol, in the 'Further Reading' section. Some of the external links are helpful for understanding the flow of an FTP transfer.
Next, brush up on iPhone socket communication. The Apple documentation for CFSocket is a good starting point. Consider using the AsyncSocket library to ease implementation.
You would begin by creating an FTP server in your application.

How to Share Files Between my iPhone App and a Mac/PC

I have developed an iPhone app which stores photos in the /Documents directory of my app.
I would like to add a feature which gives to the user the opportunity to transfer those pictures to his/her PC or Mac.
I don't really know how to do that.
What is the best way, using Bonjour, bluetooth, or directly USB (if it is possible) ?
I really need some advices on that point ...
Any ideas ?
PS: Forgive my English, I am French :-)
Try NSNetService to register the service in Bonjour, and NSFileHandle to send data over a socket connection associated with the service.
If you do not want to write a Mac or PC part for your app then you can also consider to build in a little http server that people can use to access the data in your app. There are some nice open source http servers available for Cocoa which you can find with Google.
Using Bonjour you can advertise your http server so that people can easily find it with a Bonjour enabled browser like Safari. (Your iPhone app's web server will appear automatically under the dynamic bonjour bookmarks items)
You've edited the question to say that it's about transferring photos. Could you store the photos on the iPhone's photo roll with UIImageWriteToSavedPhotosAlbum(), and let Apple handle getting them onto the computer?
Bonjour!
I mean that both as a greeting and an answer. You have to setup a bonjour connection over wifi to transfer files directly to and from an app. That's actually pretty simple to do on both the iPhone and Mac side. The PC is a little tougher.
You can do bluetooth but bluetooth capability is still fairly rare on desktops.
Without knowing more about your specific application, I agree with Graham Lee--either directly saving to the Camera Roll or giving the user an option to save one or more photos to the Camera Roll is much simpler than http/bonjour.

iphone sdk: playing video from localhost?

I have a server socket (on port 3490) in my app which has a video data - It runs on a different thread. Now I have a mpmovieplayercontroller and would like to read the data from the socket and play it. I'm not sure what url should I pass to it. I've tried file://localhost:3490
http://localhost:3490
but this doesn't work. Please help
Thanks
Alex
You say server socket but you don't mention what kind of protocol the server implements. Is it HTTP? If so then you will need to use a http URL.

WiFi iPhone Application

im working on an iPhone application which requires communication between 2 devices through WiFi.
Can somebody please help me by providing a simple iphone application code for the same which is able to communicate data between the devices...i hv gone through the "witap application" available on the developers site but wasnt able to understand it...
please help..
There's a great 2-part tutorial at MacResearch:
Part One
Part Two
Use the Bonjour , let Device A as the server, and publish service via Bonjour; and in Device B,use the NSNetServiceBrowser to search the published service via device A in the same local network,and connect by socket to send data.
there is a demo here.download.And you can read this article go>>.It helped me before.