Port listening with JScript - scripting

I'm Trying to write a plugin for NotePad++ using NppScripting - a platform for writing plugins using javascript (specifically - JScript).
I was wondering if there was a way (probably via ActiveXObject) with which I could listen to a port asynchronously (specifically - I'm trying to write a CSS-X-Fire port to NPP).
I know .NET has that capability via System.Net.Sockets but I couldn't figure out a way to access it via JScript.
Any help?

If I were doing this, I would write the Socket server in .NET as a standalone EXE.
If I understand CSS-X-Fire correctly, it is a plugin to IntelliJ Idea that listens to outgoing communications from Firebug, and then updates source files appropriately. It sounds relatively simple. The .NET socket server could do this very easily.
Then, rather than expose a 2nd interface directly from the socket server to the scripting environment - like a COM object or a COPYDATA channel or something like that - I'd use the filesystem for communication. In other words, script something in NPP that polls the filesystem file for updates. When the .NET Socket server gets a message that says "Firebug just updated file X.css", the .NET Socket server can apply those updates to the filesystem file, and save changes back to the filesystem. Because the Notepad++ app polls the filesystem, it will see the updated file and reload it, picking up those saved changes. You'd need to do cursor management within N++ intelligently.
Emacs has an "auto revert mode" for this sort of thing, so the .NET CSS-X-Fire Socket server would work with emacs out of the box - no additional scripting required. Not sure if N++ has an auto-revert equivalent.

I eventually decided to use Adobe AIR to create my solution. It provides an amazing set of APIs, including a set of Socket APIs.
You can look at my solution here

Related

PUT Stream 0 Bytes

I am using Windows Explorer to test the WebDAV implementation I am adapting to our system. The implementation is using IIS Express and is launched by Visual Studio 2013. I turned off Windows Explorer's requirement for SSL with WebDAV so I can test basic authentication (which works).
The problem I am having is with the Write method of the DavFile implementation. I connect to the web folder, navigate to a sub folder, then attempt to copy a JPG file from a folder on my computer's hard drive, into the WebDAV sub folder (using Windows Explorer).
The attempt to copy up a file (854kb) fails. When I set a break point, I notice that the "segment" stream (one of the input parameters on the "write" method, shows 0 (zero) bytes length.
Any tips on how to debug this problem? What is the most likely cause of 0 byte in the stream?
Here are some ideas about how to understand what is going wrong:
Examine the server log for exceptions. By default it is called WebDAVLog.txt and located in \App_Data\WebDAV\Logs\ folder. Are there any exceptions in it? Check your server log and make sure all requests were successful.
Examine WebDAV requests with a Fiddler tool or any other debugging proxy. While all requests that reached the WebDAV server Engine are logged, if the request failed before hitting the Engine you will not see it in a log. Usually this happens if the request failed during authentication stage.
Note that to capture requests using Fiddler on 'localhost' you must use 'localhost.fiddler' instead of 'localhost' when connecting to server, for example: http://localhost.fiddler:1234.
Exclude any client side issues. Finally there could be issues with client software that you are using, including with Microsoft miniredirector. Try to access server from any other machine. To get the idea if the problem is on the client or server side try also to reproduce the issue on ajaxbrowser.com.
You can post a part of the WebDAVLog.txt or fiddler log here or send it to IT Hit, it may give the idea of what is wrong.

Can I use Background Intelligent Transfer Service with FTP?

I am writing an application that gets its data from many small servers (the "servers" are data loggers and the app consumes the data from the loggers). The data exists as files on the server and I have been using SSH FTP to get the files. Specifically I'm using the .NET wrapper for WinSCP
I have had some problems with this, some transfer fail (while Filezilla succeeds) and it does not report progress. Also, the downloads can be long due to limited bandwidth at the server. So I would like to use BITS to do the transfers but it appears this only works with HTTP. I could switch to HTTP but I currently check what needs to be downloaded by comparing file sizes and dates on the server and the local cache. This does not seem possible using HTTP.
Is there a way to use BITS and FTP? Or is there a way to check what needs downloading with HTTP?
I have complete control over the servers. They currently run Linux and OpenSSH to facilitate the transfers. I'm using VB and .NET framework 4.0 for the application.
Thanks.
You can use a System.Net.HttpWebRequest to the web URL with a request method of "HEAD". You can then get a System.Net.HttpWebResponse and check the ContentLength and LastModified properties of the response to compare to the local cache.
e.g.
dim request as System.Net.HttpWebRequest
request=System.Net.HttpWebRequest.Create("http://...")
request.Method="HEAD"
dim response as System.Net.HttpWebResponse=request.GetResponse
dim fileLength as integer=response.ContentLength
dim fileDate as datetime=response.LastModified
obviously, you need to trap for exceptions as the GetResponse might not like it if the file isn't there or the server isn't available, etc.
Hope this helps, Regards, Denver

XPages JVM Error: err.PersistenceServiceResourceProvider.Errorwritingtopersistedcontenttor

We are running a Domino 8.5.3 and the server log is constantly issuing these errors:
HTTP JVM:
!err.PersistenceServiceResourceProvider.Errorwritingtopersistedcontenttor!
We have not been able to isloate it to a particular page. Eventually, the HTTP task will crash and we need to reboot the server and recompile all the databases on the server. We are using the CKEditor to generate the HTML content. You help would be most appreciated.
We used to get this exact error a lot which appeared to be caused by inline images uploaded via the CKEditor like Paul mentioned.
I don't know why but we fixed it by changing the directory domino uses for uploads via the
xsp property xsp.persistence.dir.xspupload (formally xsp.upload.directory)
changing it to something like c:\temp rather than the windows default made the problem go away. could have been a co-incidence but may have been something in windows interfering
I haven't seen that error before but it reads like it might be something to do with asking the server to make a lot of data available to the xpages between calls to the server- effectively, session and application scope data.

IPC between windows service and LSP DLL

I'm writing a Winsock LSP (Layered Service Provider) DLL that needs to communicate with a windows service.
The communication is done using memory mapped files and events for synchronization. Everything works fine if the application is not running as a service but if it does it cannot find any events or file mappings (I get ERROR_FILE_NOT_FOUND error on OpenEvent).
I suspect this happens because when running as a service, the application runs as SYSTEM user and LSP is loaded by applications that run as local user.
I think that this could be solved by using a proper SECURITY_DESCRIPTOR but I don't know what should it be set to.
Any ideas on how to make this work?
Thanks,
Depending on the OS, it might be a problem of sessions. If you take another look at documentation for CreateEvent, CreateMemoryMapping etc., you will notice GLOBAL\ prefix to object name. This prefix (among with SESSION\x\ prefix) define visibility scope of the object. GLOBAL prefixes are seen across the whole system, while objects without prefix in the name are local to specific (current if the \SESSION prefix is omitted) session. Sessions appeared in Terminal Services for Windows XP, then got themselves into the OS in Windows 2003 Server and later.

flex 3 and acessing remote java objects

im just starting to learn flex and im trying to understand how Flex does remoting? From what i have read it looks like Flex provides a LifeCycle data services war which sits on your server and intercepts your remote calls , is this close?
Im concerned that if i use this option that 1. Ill have to add an extra war to my server - the lifecycle data service war and 2. That i will have to pay for a license for each instance i use on each cpu.
Is there an easier [free] option out there which i can use to call my remote java objects from within my flex mxml?
Blaze DS is based off the same APIs / code base as LiveCycle Data Services and is completely free and open source:
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/
There are a number of other options available including:
Granite DS
WebOrb
FluorineFX (for .NET)
There are also solutions for PHP, Python and Ruby, although I can't recall their names right now.
Easiest option is to send xml from the server and to use it in Flex.
However if you want to use java Objects you can go for BlazeDs. It would require you to put an extra jar files (an no incensing) Also there are other options available as WebOrb for java nr meraapi.