LEADTOOLS JPEG 2000 (Leadtools.Jpip.Server assembly)
LEAD Technologies, Inc

Process Method

Example 





HTTP client request data.
Index of the first byte to decode.
The number of bytes to decode.
Read and decode a client HTTP data buffer in chunks and fill the HttpClientRequest properties.
Syntax
public void Process( 
   byte[] readBuffer,
   int offset,
   int length
)
'Declaration
 
Public Sub Process( _
   ByVal readBuffer() As Byte, _
   ByVal offset As Integer, _
   ByVal length As Integer _
) 
'Usage
 
Dim instance As HttpClientRequest
Dim readBuffer() As Byte
Dim offset As Integer
Dim length As Integer
 
instance.Process(readBuffer, offset, length)
public void Process( 
   byte[] readBuffer,
   int offset,
   int length
)
 function Leadtools.Jpip.HttpServer.HttpClientRequest.Process( 
   readBuffer ,
   offset ,
   length 
)
public:
void Process( 
   array<byte>^ readBuffer,
   int offset,
   int length
) 

Parameters

readBuffer
HTTP client request data.
offset
Index of the first byte to decode.
length
The number of bytes to decode.
Remarks

You can call this method many times to decode chunks of client data as they received from an HTTP request.

Use the Execute property to decide when the request data is completely received and decoded.

This method will update the HttpClientRequest properties and fill the Headers and Args while processing.

Example
 
Public Class HttpServerCommunication
      Private Sub ProcessClientRequests()

         Dim clientRequest As HttpClientRequest = Nothing
         Dim decoder As HttpRequestDecoder = Nothing
         Dim client As Socket

         client = GetClientSocket()
         clientRequest = New HttpClientRequest()
         Dim clientData As Byte()

         Dim received As Integer

         Do
            clientData = New Byte(client.ReceiveBufferSize - 1) {}

            received = client.Receive(clientData)


            clientRequest.Process(clientData, 0, received)

         Loop While clientRequest.Execute 'receive data until a complete request is received

         Console.WriteLine("Client request received: {0}", clientRequest.CompleteMessage)

         File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "ServerRequests.dat"), clientRequest.BodyData)
         decoder = New HttpRequestDecoder(clientRequest)

         Console.WriteLine("Server will process client image {0}", decoder.Fields.RequestTargetFields.Target)


         'Process client request...
         '...

         client.Close()
      End Sub

      Private Function GetClientSocket() As Socket

         Dim listenSocket As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)

         Dim hostIP As IPAddress = IPAddress.Parse("127.0.0.1")
         Dim port As Integer = 107

         Dim ep As IPEndPoint = New IPEndPoint(hostIP, port)

         listenSocket.Bind(ep)

         ' start listening
         listenSocket.Listen(10)

         'a client should send a request to the listening address
         Dim client As Socket = listenSocket.Accept()

         listenSocket.Close()

         Return client
      End Function
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void ProcessClientRequests()
         {
#if LEADTOOLS_V175_OR_LATER
            Leadtools.Examples.Support.SetLicense();
#else
            Leadtools.Examples.Support.Unlock();
#endif // #if LEADTOOLS_V175_OR_LATER
            HttpClientRequest clientRequest = null;
            HttpRequestDecoder decoder = null;
            Socket client;
            client = GetClientSocket();
            clientRequest = new HttpClientRequest();
            byte[] clientData ;
            int received;
            do
            {
               clientData = new byte[client.ReceiveBufferSize];
               received = client.Receive(clientData);
               clientRequest.Process(clientData, 0,  received);
            } while (clientRequest.Execute); //receive data until a complete request is received

            Console.WriteLine( "Client request received: {0}", clientRequest.CompleteMessage);
            File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "ServerRequests.dat"), clientRequest.BodyData);
            decoder = new HttpRequestDecoder(clientRequest);
            Console.WriteLine( "Server will process client image {0}", decoder.Fields.RequestTargetFields.Target);
            //Process client request...
            client.Close();
         }

         private Socket GetClientSocket()
         {
            Socket listenSocket = new Socket( AddressFamily.InterNetwork,
                                              SocketType.Stream,
                                              ProtocolType.Tcp);
            IPAddress hostIP = IPAddress.Parse("127.0.0.1");
            int port = 107;
            IPEndPoint ep = new IPEndPoint(hostIP, port);
            listenSocket.Bind(ep);
            // start listening
            listenSocket.Listen(10);
            //a client should send a request to the listening address
            Socket _client = listenSocket.Accept();
            listenSocket.Close();
            return _client;
         }

   static class LEAD_VARS
   {
      public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
   }
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

HttpClientRequest Class
HttpClientRequest Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Jpip.Server requires a Document or Medical license and unlock key as well as a server license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features