Aurora Visio Studio TOP » Program Examples » IO HTTP Image Download

IO HTTP Image Download

目的

The task is to download an image from www.adaptive-vision.com using TCP IP connection.

Input

A hostname of website to connect to.

Output

The downloaded image messe.jpg and information about it.

ヒント

To download the messe.jpg image from www.adaptive-vision.com you need to send the following query string through connected TCP socket: GET /site_media/native/content/messe.jpg HTTP/1.0. The task can be easily solved using filters from the TCP IP category and LoadImageFromBuffer filter.

Enable sections by clicking on the Show Sections () button.

Solution (AVS)

  1. Add TcpIp_Connect filter to connects as a client to server socket.
  2. Add TcpIp_WriteText filter to send query string and header through a connected TCP socket.
    • Connect its input inSocket with output of TcpIp_Connect filter.
    • Set inText to: GET /site_media/native/content/messe.jpg HTTP/1.0 Host: www.adaptive-vision.com Accept: image/* Connection: close.
    • Set inSuffix to \r\n\r\n.
  3. Add TcpIp_ReadLine filter to read response headers and connect it with output of TcpIp_Connect filter.
  4. Add TcpIp_ReadAllBuffer to receive data from a connected socket. Set inTimeout to 2000.
  5. To convert received data from a ByteBuffer type to an Image type add LoadImageFromBuffer filter and connect its input inBuffer to output of TcpIp_ReadAllBuffer filter.
  6. To close socket add TcpIp_Close filter.

マクロフィルタ メイン

使用したフィルタ

アイコン 名前 説明
LoadImageFromBuffer Use this filter when you received an image file through I/O communication, e.g. through a TcpIp connection.
TcpIp_ReadAllBuffer Receives data from a connected socket until the other side closes connection.
TcpIp_WriteText Outputs a string through a connected TCP socket.
TcpIp_ReadLine Reads from a connected TCP socket until receiving a specific sequence.
TcpIp_Connect Connects as a client to a remote TCP server socket.
TcpIp_Close Closes a connected TCP socket gracefully.

その他の資料