Using an writestream directly to an IP and port in ios - iphone

I'm trying to create an app that is able to send a .pdf-file directly to a printer from an iPhone. I'd like to create a raw socket connection. I should be able to open a stream to a specific IP-adress and a port. Then I'd like to throw that .PDF-file into the stream so the printer (or my server on the computer) receives it.
I've made a stream already using ftp. Ofcourse, printers don't handle ftp-protocols. That is why I want to send the data in a raw stream to the device's port.
Any idea how I can accomplish this?

CocoaAsyncSocket is really easy to use and has good documentation. It is an objective-c wrapper around lower level socket primitives. It sounds like all you need is to write data out to a socket. If so then it is the easiest way to go.

Related

Is it possbile to stream video to a server using an esp32 cam?

I need to stream video data to a server from an ESP32-cam. So I need to set the esp32-cam as a client, but I could not find any example code or any resource regarding how to stream video data to a server. There are example that show how to set ESP32-cam as a video streaming server, but not client. I could not find any resource. Is this possible at all?
Or as an alternative solution, would it be possible to connect the esp32-cam server to another server?
I would appreciate if you could give any resources.
Thanks in advance!
I think you mean you want the camera to act like an IP-Camera and send its stream to a server so you can then stream the video from that server.
Many servers for IP cameras will be set up to receive RTSP streams - there are example libraries to send a RTSP stream from your esp32-cam which you can use for this. One popular example: https://github.com/geeksville/Micro-RTSP
As a note, you could also have your server act as a client when you esp32-cam acts as a streaming server. It could then re-stream the video to wherever ever you want to send it.

Saving data that's being sent to a process through TCP/IP

I want to capture and save the data that's being sent to a certain process through internet .
Are there any tools for the job?
If not, does listening to the same port as the process that I'm trying to get data from, will get me the data?
Any help appreciated !
You can try Wireshark: http://www.wireshark.org/
Or RawCap: http://www.netresec.com/?page=RawCap
I don't know what is the data format you are trying to capture. I used these two tools to capture xml data from web service.
On Windows, use Winsock Packet Editor (WPE). You will be able to hook a process' all Winsock-related functions and capture (and even modify/block) any TCP/IP, UDP packets that the application receives or sends. For all other operating systems, you will have to either:
write your own tool that hooks various socket functions (e.g. send, recv, etc.)
or just use Wireshark which will capture all Layer-3 packets that goes through your network card. You will have to use your own knowledge of the application that you're trying to monitor in order to filter the packets that are specific to the application.
Are there any tools for the job?
Wireshark. But what have you tried?
If not, does listening to the same port as the process that i'm trying to get data from, will get me the data?
Not if you don't forward the traffic to the real destination, otherwise the other party will be waiting forever on a response, or simply timeout and close the connection. You should create something like a proxy.
Wireshark is easier.

What application layer protocol does Google Goggles and Layar use?

These applications stream video from client app to their own server. I am interested in knowing what type of protocol they use? I am planning on building a similar application but I dont know how to go about the video streaming. Once I get the stream to my server I will use OpenCV to do some processing and return the result to the client.
I recommend you to send only a minimum of data and do the processing as much as possible on the client. Since sending the whole video stream is a huge waste of traffic (and can not be done in realtime I think)
I would use a TCP connection to send an intermediate result to the server, that the server can process further. The desing of that communication depends on what you are sending and what you want to do with it.
You can wrap it in xml for instance, or serialize an object and so on.

Windows Phone 7 Connection with a wifi-enabled micro controller

How can i connect a windows phone 7 device with a WiFi-enabled micro controller. Should i use socket programming?? If yes then how?? I actually want to send a text file or a text message to the micro controller using WI-FI??
Your question is a bit vague. Are you trying to write a app that enables you to send a text file/message?
or are you trying to accomplish this by connecting to the microcontroller with the default connection your phone provides.
If you want to write your own app, you can do this by using a windows socket function. Have you looked into the standard code examples windows provides? They provide good examples about the basis of windows phone wifi connectivity
in example:
Example 1
Example 2
Edit:
You should take a look at this example.
Example
In this microsoft example, they make the game tic tac too between two windows phones. For your cause, you can read the data form file. Temporarly store it in an array. And send it over wifi. if you customize the example to fit your needs, so in steps:
Declare a socket (with the right ip adresses, ports etc)
Read file
Store in array
Send array by the wifi (using your previously declared socket)
And then on the microcontroller, you need some way to filter your data out of the incomming wifi buffer. I looked into one of my older projects where i did something like this. But i couldn't find it anymore. So i must have deleted it at some point "sorry :( " i you can work this out using the example

How to make iPhone host like a stream web server

By reference http://www.subfurther.com/blog/2010/12/13/from-ipod-library-to-pcm-samples-in-far-fewer-steps-than-were-previously-necessary/, I have get AVAssetReader, how to create a url like "http:///a.mp3", so other machine can access this mp3 to download or play?
When you get a connection, write this header
char * header = "ICY 200 OK\r\n"
"icy-name:iPhone FM\r\n"
"icy-url:http://iphone-fm.com/\r\n"
"content-type:audio/mpeg\r\n"
"\r\n";
then simply write the raw mp3 data down the socket.
I'm not sure if you want to serve the mp3 as a file, or as streaming radio. If as a file, you should probably set the content length. If as a radio stream, then you should check out
http://www.smackfu.com/stuff/programming/shoutcast.html
and maybe implement streaming metadata for the song title, etc.
It's not trivial. Of course you could technically do it, since an iPhone has a full fledged TCP/IP stack. But, for a server you need to know its address before connecting to it.
What I've seen done in these cases is:
Turn on your APP
Show the URL to connect to based on its current address (you will probably be only able to connect through WIFI)
Use the client to connect to your iPhone Server.
Do keep in mind that this is extremely user unfriendly. You might want to consider a proxy server from your iPhone to the rest of the world in the middle.