Recent Posts

Pages: 1 ... 8 9 [10]
91
SSH / Re: SSH ChannelReadAndPoll, dont wait and exit when everything was recieved ?
« Last post by marhyno on March 08, 2018, 07:46:43 AM »
Unfortunately this doesnt work, I wont even fetch any output from the device. I commented out the ChannelReadAndPoll and added ChannelReceiveToClose. But this time I dont get any output.

/*THIS IS THE SET OF COMMANDS I WANT TO RUN */
            success = end_device.ChannelSendString(channelNum, command, "ansi");

            if (success != true)
            {
                result = "Execution of commands failed";
                return Tuple.Create(false, result);
            }

            // Wait and fetch streaming output from Device
            /*var cmdOutput = end_device.ChannelReadAndPoll(channelNum, 30000);
            if (cmdOutput < 0)
            {
                  result = end_device.LastErrorText;
                  return Tuple.Create(false, result);
            }*/

            /* SEND END OF COMMANDS */
            success = end_device.ChannelSendEof(channelNum);
            if (success != true)
            {
                result = "Execution of commands failed";
                return Tuple.Create(false, result);
            }

            //  After recieving output close the channel:
            success = end_device.ChannelSendClose(channelNum);
            if (success != true)
            {
                result = end_device.LastErrorText;
                return Tuple.Create(false, result);
            }

            //  After recieving output close the channel:
            success = end_device.ChannelReceiveToClose(channelNum);
            if (success != true)
            {
                result = end_device.LastErrorText;
                return Tuple.Create(false, result);
            }

            if (success)
            {
                result += end_device.GetReceivedText(channelNum, "ansi");
                return Tuple.Create(true, result);
            }
92
I want to encrypt using a public key and decrypt using the private key from a certificate in the windows certificate store.
The goal is to encrypt text files with a public key and install the certificate with the private key for specific users to enable them to decrypt the files using the private key
I preferly want to put the certificate on a gemalto smartcard and also require the certificate to be able to login to the webserver where the files will be presented and then use the private key of the certificate on the gemalto smartcard to decrypt the files.
93
SSH / Re: SSH ChannelReadAndPoll, dont wait and exit when everything was recieved ?
« Last post by marhyno on March 07, 2018, 04:57:18 PM »
So you are saying I should not use the ChannelReadAndPoll method at all ? Honestly I dont believe this will work but I will give it a try. Just for you imagination I am pasting commands to cisco switches / routers. This works fine but the last command which tells the switch to save config has delay before it starts and also it takes some time during execution (displaying progress of saving to the disk). So it happens that sometimes I see just last command without the output or half of the output from the last command (e.g. progress till 58% of saving) because the sessions disconnects from the switch. Do you really think I should use it without this method ? Will I get any output from this ? Or how the application will know when it needs to disconnect ? I dont really understand the ChannelSendEof method (like when it is executed, or how it knows when it should be executed or like it will not interrupt exeuctions and getting outputs from many commands ?) So far, thanks for the suggestion :)
94
SSH / Re: SSH ChannelReadAndPoll, dont wait and exit when everything was recieved ?
« Last post by Chilkat on March 07, 2018, 04:11:56 PM »
I think you should be able to do things in this order:

  • Call ChannelSendString
  • Call ChannelSendEof
  • Call ChannelSendClose
  • Call ChannelReceiveToClose
  • Call GetReceivedText

The pollTimeoutMs argument pased to ChannelReadAndPoll is intended to be a small time duration.  It's a method where the intent it to read incoming data, and keep reading until data stops arriving.  The call will return when data stops arriving for the amount of time specified by pollTimeoutMs.  This means that any call to ChannelReadAndPoll will not return for at least pollTimeoutMs.  (It's a call good for certain situations, but not your particular situation..)
95
Compression / Archives / Archive testing.
« Last post by Vitali on March 07, 2018, 03:50:28 PM »
Hello,

is it possible to test archive for errors before unzipping?
96
SSH / SSH ChannelReadAndPoll, dont wait and exit when everything was recieved ?
« Last post by marhyno on March 07, 2018, 02:30:16 PM »
Hi, I am having trouble tuning my application. I am trying to find best possible solution how to execute commands on device, wait for output and then disconnect. Problem is sometimes getting output takes about 15-20 seconds, therefore I used also ChannelReadAndPoll command. But I see that when I set up this command to have timeout 30 seconds, It waits also around 30 seconds when it already gets all the output which is time wasting.

How can I tune the application, so when it gets all the output or a specific line faster It can disconnect.

/*THIS IS THE SET OF COMMANDS I WANT TO RUN */

              success = end_device.ChannelSendString(channelNum, command, "ansi");

              if (success != true)
              {
                    result = "Execution of commands failed";
                    return Tuple.Create(false, result);
              }

              // Wait and fetch streaming output from Device
              var cmdOutput = end_device.ChannelReadAndPoll(channelNum, 30000);
              if (cmdOutput < 0)
              {
                    result = end_device.LastErrorText;
                    return Tuple.Create(false, result);
              }

              /* SEND END OF COMMANDS */
              success = end_device.ChannelSendEof(channelNum);
              if (success != true)
              {
                    result = "Execution of commands failed";
                    return Tuple.Create(false, result);
              }

              //  After recieving output close the channel:
              success = end_device.ChannelSendClose(channelNum);
              if (success != true)
              {
                    result = end_device.LastErrorText;
                    return Tuple.Create(false, result);
              }

              if (success)
              {
                    result += end_device.GetReceivedText(channelNum, "ansi");
                    return Tuple.Create(true, result);
              }
97
REST / HTTP / HTTPS / Re: Write an HTTP Server using Chilkat?
« Last post by Chilkat on February 28, 2018, 09:48:32 AM »
There is no simple solution.  Yes, one *can* write a simple HTTP server.   If one Google's "write an HTTP server", you'll get results such as "Write an HTTP server in 500 lines or less" or "Write a simple HTTP server", etc.   Whatever implementation you find by following these links is likely to be just a fragile toy.

You can write an HTTP server with limited functionality which may serve your needs.  It's important to fully understand the scope of what's potentially involved in writing an HTTP server, so you can understand what cababilities your simple implementation may lack.

If I were to begin writing an HTTP server, this is how I would begin.   (First, I would purchase the O'Reilly book "HTTP: The Definitive Guide" as a reference.  Reading the 1st few chapters is good for a fundamental understanding. The remainder is good for reference.  No need to read these books end-to-end.  Eventually, you'll have read it all many times over if you work often with HTTP..)

So here are the steps:

1) Design your architecture for receiving incoming connections and how each accepted connection is handled (perhaps in it's own thread).  We're just talking about non-SSL/TLS port 80 for now.

2) An incoming HTTP request begins with a "start line" ending with a CRLF.  Read that and parse it.  (You need a socket API that can read the socket until a particular desired string is returned.  Chilkat Socket provides a ReceiveToCRLF method.)

3) HTTP requests and responses are MIME.  The HTTP request MIME header follows the start line, so you can read until a double-CRLF is received.  (MIME headers are separated from MIME bodies with a double CRLF.)   For example, you could call Chilkat.Socket.ReadUntilMatch("\r\n\r\n");   

4) You can parse the MIME header using Chilkat.Mime (or CkMime in some programming languages).   Load the HTTP request MIME header by calling Chilkat.Mime.LoadMime.  Now you have access to information about the request.  In the simple case, you'll find a Content-Length header field that indicates the exact number of bytes that constitute the MIME body of the request, which should follow the MIME header. 

5) Read the number of bytes indicated by Content-Length.  Don't assume you have text.  Call Chilkat.Socket.ReceiveBdN to read the MIME body.   But first, append the MIME header to the Chilkat.BinData object you pass to ReceiveBdN.  The ReceiveBdN method will append incoming bytes to the BinData object.  Now you have the full HTTP MIME request in a BinData object.  Create a new Chilkat.Mime object instance and load the full MIME by calling Mime.LoadMimeBd.   This solves a huge amount of potential complexity because the Chilkat.Mime class is correctly handling encodings, charsets, etc.  You can now access the parts of the HTTP request via the Chilkat.MIME API.

6) The response you formulate is similar to the HTTP request.  It's a "start line" followed by the HTTP response, which is MIME.  You could potentially use Chilkat.Mime to compose your response, or you could emit the response as you see fit.  The important part of the response is to ensure the value in the Content-Length response header is the exact raw size of the MIME body that follows.




The above is just the start..  It's still just a toy because there are potentially a huge number of things to consider:

1) Will "chunked encoding" HTTP requests be received?  Should for large responses, should "chunked encoding" responses be sent?

2) How to handle Authentication?  (If a request uses an Authorization header.)

3) Handle the "Expect: 100-continue" header.

4) What if the request uses a gzip Content-Encoding?  Would you want to send a compressed response?

5) How to listen on port 443 w/ TLS?  (Chilkat.Socket can do it, but you'd need a certificate, possibly self-signed if the client doesn't care..)

6) What about anything to do with proxies?

Anyway.. the list goes on and on.  You can build a simple HTTP server, with the awareness of what's lacking so you're not surprised when something's not working because a particular feature is needed. Then, of course, you could add features over time until one day you'll have something that's truly not a toy anymore..  :)
98
REST / HTTP / HTTPS / Write an HTTP Server using Chilkat?
« Last post by Chilkat on February 28, 2018, 09:13:28 AM »
I need to write a small http server to get remote access to my application. I tried to find anything that I could use to write a http server in the Chilkat library. Didnít find anything, but just wanted to be sure that I havenít missed anything before finding another simple solution.
99
FTP / Failed to connect FTP Server.
« Last post by PureAppsIT on February 28, 2018, 05:58:58 AM »
Respected Sir/Mam',
                                I want to retrieve files from FTP server using CHILKATDOTNET, I've tried for same based on details(Host name,Username,Password,Port) but I can't get success.
I need help for retrieve files from server using chilkatdotnet. If you share demo program for same then I think It would be great.

I'm very much awaiting for your reply.

Yours faithfully,
PureAppsIT
100
ActiveX / Re: VB 6 CODES FOR CONVERTING BASE64 STRING TO IMAGE
« Last post by Chilkat on February 26, 2018, 09:29:04 AM »
Here are links to an example:

(You'll find a "Visual Basic 6.0" example in the list..)


Decode Base64 Image String (GIF, JPG, etc.) and Save to File

Android: http://www.example-code.com/android/base64_image.asp
Classic ASP: http://www.example-code.com/asp/base64_image.asp
C: http://www.example-code.com/C/base64_image.asp
Chilkat2-Python: http://www.example-code.com/chilkat2-python/base64_image.asp
C++: http://www.example-code.com/cpp/base64_image.asp
C#: http://www.example-code.com/csharp/base64_image.asp
C# UWP/WinRT: http://www.example-code.com/csharp_winrt/base64_image.asp
DataFlex: http://www.example-code.com/dataflex/base64_image.asp
Delphi ActiveX: http://www.example-code.com/delphiAx/base64_image.asp
Delphi DLL: http://www.example-code.com/delphiDll/base64_image.asp
.NET Core C#: http://www.example-code.com/dotnet-core/base64_image.asp
Excel: http://www.example-code.com/excel/base64_image.asp
Visual FoxPro: http://www.example-code.com/foxpro/base64_image.asp
Java: http://www.example-code.com/java/base64_image.asp
Lianja: http://www.example-code.com/lianja/base64_image.asp
MFC: http://www.example-code.com/mfc/base64_image.asp
Mono C#: http://www.example-code.com/mono/base64_image.asp
Node.js: http://www.example-code.com/nodejs/base64_image.asp
Objective-C: http://www.example-code.com/objc/base64_image.asp
Perl: http://www.example-code.com/perl/base64_image.asp
PHP ActiveX: http://www.example-code.com/phpAx/base64_image.asp
PHP Extension: http://www.example-code.com/phpExt/base64_image.asp
PowerBuilder: http://www.example-code.com/powerbuilder/base64_image.asp
PowerShell: http://www.example-code.com/powershell/base64_image.asp
PureBasic: http://www.example-code.com/purebasic/base64_image.asp
Python: http://www.example-code.com/python/base64_image.asp
Ruby: http://www.example-code.com/ruby/base64_image.asp
SQL Server: http://www.example-code.com/sql/base64_image.asp
Swift: http://www.example-code.com/swift/base64_image.asp
Tcl: http://www.example-code.com/tcl/base64_image.asp
Unicode C: http://www.example-code.com/unicodeC/base64_image.asp
Unicode C++: http://www.example-code.com/unicodeCpp/base64_image.asp
Visual Basic 6.0: http://www.example-code.com/vb6/base64_image.asp
VB.NET: http://www.example-code.com/vbnet/base64_image.asp
VB.NET UWP/WinRT: http://www.example-code.com/vbnet_winrt/base64_image.asp
VBScript: http://www.example-code.com/vbscript/base64_image.asp
Xojo Plugin: http://www.example-code.com/xojo/base64_image.asp


Pages: 1 ... 8 9 [10]