Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 108

Thread: VB6 Web Site/App Server

  1. #41
    Banned
    Join Date
    May 2020
    Location
    https://t.me/pump_upp
    Posts
    42

    Re: VB6 Web Site/App Server

    I tried to test it on my machine but got the following error

    Public Function dateVbLocalToVbUtc(ByVal p_LocalDate As Date) As Date
    ''dateVbLocalToVbUtc = p_LocalDate - New_C.UTC.LocalOffs
    End Function

    When I tried removing it, it worked fine... the code in that project was too difficult for me to edit...

  2. #42

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    What was the exact error message?

  3. #43
    Banned
    Join Date
    May 2020
    Location
    https://t.me/pump_upp
    Posts
    42

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    What was the exact error message?
    Thank you, I don't understand why... when I run the code for the first time, it gives me an error... after I run it again, it doesn't give an error anymore... the code in that project involved many problems, so I do not know too

    Name:  Capture.jpg
Views: 846
Size:  27.4 KB
    Last edited by PhuongNam; Dec 24th, 2021 at 07:47 PM.

  4. #44

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    I'm not sure when the UTC class was added to RC6 (I only noticed myself a few days ago or so). I would try updating RC6 to the latest version available at vbrichclient.com. It should be version 6.0.9 to be compatible with this project.

  5. #45
    Banned
    Join Date
    May 2020
    Location
    https://t.me/pump_upp
    Posts
    42

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    I'm not sure when the UTC class was added to RC6 (I only noticed myself a few days ago or so). I would try updating RC6 to the latest version available at vbrichclient.com. It should be version 6.0.9 to be compatible with this project.
    I use the old version so I report that error ( RC6.dll Version 6.0.0.4 )
    I just downloaded the new version and it's good to use

  6. #46

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Great, glad it's working now

  7. #47
    Fanatic Member
    Join Date
    Jun 2016
    Location
    España
    Posts
    514

    Re: VB6 Web Site/App Server

    good job work perfect

  8. #48
    Addicted Member jg.sa's Avatar
    Join Date
    Nov 2017
    Location
    South Australia ( SA )
    Posts
    200

    Re: VB6 Web Site/App Server

    G'Day Bro

    I missed this 'upgrade' as I have been very busy with the summer of cricket ( SOC ) and the Aussies thrashing the poms at their own game

    This code change is exactly what I have been wanting to do, it is a bit scary how you are able to read my mind !!!

    Keep up the gr8 work.

    I will be ready in a couple of weeks to create the contacts system I have been designing as a web version of outlook, internal name saseCon.

    The SOC allows me to cut code in front of the TV, so are you pausing dev. on this system in the near future, I will probably need 10 days, funny that being 2 x cricket test matches.

    Then I can hand it back with a very poor UI for you or someone else to tart up.

    I was thinking of using TABS so it is similar looking to Outlook forms, do you have any ideas / prefs ?

  9. #49

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    I thought I would share my experience migrating VBWebAppServer to TwinBasic:

    I used the new Import from Visual Basic feature of TwinBasic, and overall it has worked surprisingly well:

    Name:  TBImportFromVB96.jpg
Views: 802
Size:  46.3 KB

    Off the bat though, I had a few issues appear in the Problems pane. One is currently unresolvable, One required a code change, and the rest were warnings that were my fault. I forgot to declare a return variable type, so the compiler warned that it would default to a Variant. In all of those cases, I didn't want a Variant type so this was a very nice warning to get!

    The unresolvable issue is that tB's App object doesn't have a ProductName property (yet), so I will have to open an issue for this. In the meantime, I've just cleared out that code and use App.ExeName instead (which is supported).

    The issue that required a code change was that I was using App.LogMode for InIDE testing. tB's App object doesn't support LogMode, so I had to switch that code to the new App.IsInIde property. No big deal.

    One note about errors in tB. Right now you get a squiggly underline on an error in tB. It would be nice to have an option to also highlight or outline the whole line of code. I'm used to seeing a red highlighted code line in VB6, and it really jumps out more.

    Anyway, after getting rid of a handful of errors and warnings, I want to try to compile the EXE. It took a minute to find out where to compile the EXE as I am used to going to the File menu > Make. I couldn't find a build option in any menu, but I did eventually find the Build icon down in the TWINBASIC tool pane:

    Name:  TBBuild96.jpg
Views: 773
Size:  48.4 KB

    Just a thought, but it might be better to have the Build button beside the Active Build combo, so that all the build related stuff is together and more easily discoverable:

    Name:  TBBuildIdea96.jpg
Views: 784
Size:  46.3 KB

    Back to the matter at hand, I finally tried compiling to a Win32 target EXE. At first I was confused because clicking the Build button didn't seem to do anything other than flash the cursor. I tried it a few times, and nothing. Assuming the compiler had crashed, I tried the "Restart Compiler" and then tried rebuilding, but no dice.

    I then thought to check the other tabs (output, terminal, and debug console) and finally I saw that the Debug Console window was showing that the linker was successfully creating the output file. It would be nice if tB would do something like popup a toast window, or automatically switch you to the debug console when Build is clicked, so you know it has actually done some work.

    Name:  TBDebugConsoleTab.jpg
Views: 791
Size:  28.9 KB

    Another thing related to compiling that would be nice: In the debug console window, it shows a SUCCESS message upon compile with a link to the compiled EXE. Ctrl+Clicking the link attempts to open the EXE in VS Code, which isn't very useful. Right-click options to Open Target Folder, Launch EXE, and Open Target Folder in Command Prompt (for command line only builds) would be very handy.

    Once compiled, the first difference I notice is the file size. 220kb for VB6 vs. 847kb for tB. That's to be expected though as tB executables run without needing a separate runtime. It's also early days for the tB compiler/linker so perhaps it will produce somewhat smaller binaries in the future (perhaps not though as more features get added!). Might be interesting to have an option to have tB split out a separate tb.dll to the Build and let the EXEs share it. This would be especially useful for use-cases like VBWebAppServer, where I may be running hundreds of instances.

    It was now the moment of truth, let's run this thing! The command-line run produced no errors, and visiting http://127.0.0.1:8080 produced this:

    Name:  TBVBWebAppServed.jpg
Views: 678
Size:  17.2 KB

    Successful!

    Or was it? I decided to check the memory situation again to see how tB binaries compared to VB6. When running a VB6 compiled instance of VBWebAppServer, memory seems to stabilize at 13-14MB no matter how many times I refresh the page in my browser. The tB compiled instance seems to have a memory leak, after continually refreshing the page in the browser, memory use slowly climbed (occasionally falling back a bit, but then continuing to climb never to be fully released). I'm not yet sure if this is a bug in my code that the VB6 compiler is smarter about handling without chewing up memory, or if it's a bug in the tB compiler. I'll have to run some more tests.

    Lastly, I would like to have tested a 64-bit build to, but VBWebAppServer references a 32-bit DLL (RC6), so this is currently impossible. I'd be interested to know from Olaf if there is any possibility to compile a 64-bit version of RC6, or if there it relies too much relying on a 32-bit environment for this to be possible. Also, I'd be curious to know if some kind of 32-bit AXDLL <->64-bit tB EXE "bridge" could be created, or if this is technically impossible or just plain too difficult? My use-case would be to create Office Add-ins that use some RC6 objects (CRpcConnection, CCollection, CConnection, & CRecordset - none of the visual Cairo stuff though). Again, I have no idea if such a thing is possible, but if so, then it would be awesome.

    In the end, I'm very impressed with tB so far. It was relatively painless to take a non-trivial VB6 application and get it to compilie with tB. I'm looking forward to seeing tB continue to develop!
    Last edited by jpbro; Dec 28th, 2021 at 02:13 PM.

  10. #50
    Member
    Join Date
    Nov 2018
    Posts
    56

    Re: VB6 Web Site/App Server

    Thanks jpbro, great to see a real world experience of porting to twinBASIC. Note that AppObject support is still in progress - see https://github.com/WaynePhillipsEA/twinbasic/issues/143. Also, multi-threading support is planned, so in future you might not need to use multiple processes to scale.

  11. #51

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Hi @mansellan, yes you are right I shouldn't have opened a new issues for the App object...I thought for sure I searched for it, but maybe I just searched for the missing "Screen" object because I was trying to compile some other code that uses Screen.MousePointer and it was failing. Sorry for the noise over there!

    Re: multi-threading, it will be interesting the see how this gets implemented in tB. Right now I use Olaf's RC6 mutli-threading classes with success when I need that, but for app servers I've recently started using a separate process per connection approach for a few reasons:

    1) Sometimes it can be nice to have access to 2GB of RAM per connection (rare, admittedly).
    2) A crash only takes down one request, not X requests.
    3) A deadlocked or infinitely looping process only costs you one responder, while threaded may cost you X responders.
    4) A watchdog can terminate a busted process relatively cleanly, but not so much for terminating a thread.

    Granted that 2 & 3 shouldn't happen in a perfect world, but sometimes my code has bugs (please don't tell anyone)!

  12. #52

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jg.sa View Post
    I missed this 'upgrade' as I have been very busy with the summer of cricket ( SOC ) and the Aussies thrashing the poms at their own game
    Sounds good to me, it's winter here on this side of the globe, albeit a bit of a mild one so far.

    Quote Originally Posted by jg.sa View Post
    This code change is exactly what I have been wanting to do, it is a bit scary how you are able to read my mind !!!

    Keep up the gr8 work.
    I'm gifted that way Keep in mind that this is very much a work in progress, so bugs are likely, and everything is still subject to change.

    Quote Originally Posted by jg.sa View Post
    I will be ready in a couple of weeks to create the contacts system I have been designing as a web version of outlook, internal name saseCon.

    The SOC allows me to cut code in front of the TV, so are you pausing dev. on this system in the near future, I will probably need 10 days, funny that being 2 x cricket test matches.
    When you get a chance to give it a try, let me know if you run in to any problems/bugs and I will do my best to help.

    Quote Originally Posted by jg.sa View Post
    Then I can hand it back with a very poor UI for you or someone else to tart up.

    I was thinking of using TABS so it is similar looking to Outlook forms, do you have any ideas / prefs ?
    Well, UI stuff isn't my strongest area, but tabs are generally understood. They seem to be rare on the web though, with slide-out hamburger menus being more popular these days. Might be something to consider.

  13. #53

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    I just changed the attachment in the first post to the latest version. No major changes, I just made some modifications so that the project can be imported into TwinBasic without getting any errors/warnings.

  14. #54

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Looks like TwinBasic did have a memory leak after all, but Wayne has fixed it in version 0.13.60. I can confirm that VBWebAppServer no longer appears to be leaking memory when compiled with the latest version TwinBasic. Thanks Wayne!

  15. #55

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Just updated the source in post #1 with a small change. I stupidly forgot to set the "AsHex" parameter in some RC6 SHA method calls, so it was returning byte arrays that were being concatenated with strings. There's no new functionality.

  16. #56
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    162

    Re: VB6 Web Site/App Server

    Dear Sir!
    I can't run this interesting project at my machine (Win10 64)

    1) I'm placed files into /App/System (cairo_sqllite.dll,DirectCOM.dll,RC6.dll(version: 6.0.0.9))
    2) Compile VBWebAppServer.exe to the folder /App
    3) Then start the server
    VBWebAppServer.exe /spawn 10/ip 127.0.0.1 /port 5000
    4) In browser go to the 127.0.0.1:5000
    nothing happens

    p.s. also, if i'm type port 8080, then i getting error like yokesee above:
    ***ERROR: -2147221504 An instance is already running at 127.0.0.1:8080


    Name:  vb_server_in_use.jpg
Views: 679
Size:  11.9 KB
    Ten Years After - 01 You Give Me Loving

  17. #57

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    It sounds like everything is setup properly and the command line looks good, so I'm not sure what's going wrong. Are you sure you've compiled the latest version (available in the first post)?

  18. #58

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    A couple of others things to consider:

    Some browsers now assume https:// if you don't supply a protocol. Does going to http://127.0.0.1:5000 work?

    It's possible that your firewall is blocking VBWebAppServer.exe, so make sure you've allowed it to have network access.

  19. #59
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,654

    Re: VB6 Web Site/App Server

    That error looks pretty clear. It looks like he is running multiple instances and your project is checking for that.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  20. #60
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    162

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    A couple of others things to consider:

    Some browsers now assume https:// if you don't supply a protocol. Does going to http://127.0.0.1:5000 work?

    It's possible that your firewall is blocking VBWebAppServer.exe, so make sure you've allowed it to have network access.
    Yes, http is work!

    but only on 5000 port.
    8080 don't work.
    After command /stop also don't work.
    Ten Years After - 01 You Give Me Loving

  21. #61

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Niya View Post
    That error looks pretty clear. It looks like he is running multiple instances and your project is checking for that.
    There's a "watchdog" running in the spawner class that checks periodically to make sure that the listener classes have bound to the network adapter and are serving data. After a certain number of failures, the watchdog will kill the apparently broken listener process and restart it. If port 5000 works, but port 8080 doesn't, then I suspect that something else is already listening on port 8080 and that's why it is failing.

  22. #62

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Quote Originally Posted by sergeos View Post
    Yes, http is work!

    but only on 5000 port.
    8080 don't work.
    If port 5000 works, but port 8080 doesn't, then I would suspect that there's another application already running that is using port 8080. Can you confirm whether or not this is the case?

    After command /stop also don't work.
    Do you get any error messages when running /stop? Does /stop work when running listeners on port 5000 and fail when running listeners on port 8080, or does /stop never work?

  23. #63
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    564

    Re: VB6 Web Site/App Server

    Use netstat -b -n in command prompt or SysInternals TCPView to find which program is using the port. No need to guess when there are tools.

  24. #64

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    I have found a couple of issues that need addressing with the watchdog, so I will have a fix for those soon.

    I'm also trying to find a good way to determine if a port is already in use when I attempt to spawn a listener on such a port. It looks like the RC6 cWebServer.Listen method doesn't raise an error (or have a return value to test) when it tries to bind to an ip/port that is already bound to another app. I've tried using the RC6 cTcpClient object, but the Connect method always returns a hSocket (even when there's nothing listening on the port I'm trying to connect to). cTcpClient.SendData looks like it should do the trick - it does timeout after about 5 seconds if there's nothing actually listening on the port, but I'm not sure I want to wait 5 seconds for each CAppServer class to come online (if I can help it). Anyway, I'll continue trying to see if I can figure out a better way to do this.

  25. #65
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,654

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    I'm also trying to find a good way to determine if a port is already in use when I attempt to spawn a listener on such a port. It looks like the RC6 cWebServer.Listen method doesn't raise an error (or have a return value to test) when it tries to bind to an ip/port that is already bound to another app.
    This is alarming. It should raise an error when trying to listen on a Port/IP combo that is already in use. I think Olaf should be notified of this because this is quite serious in my opinion.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  26. #66
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,654

    Re: VB6 Web Site/App Server

    I sent him a PM. Hopefully he can look into it for you or suggest something you haven't thought of.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  27. #67

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    I think it might be by design actually, using a non-blocking connection that returns immediately. I don't know enough about winsock programming to be sure, but there's a call to the ws2_32.connect function that explicitly ignores error 10035 (WSAEWOULDBLOCK), assumably on the presumption that the connection will eventually succeed.

    I think I'll have to roll my own "blocking" connection: https://docs.microsoft.com/en-us/cpp...?view=msvc-170. Maybe a "blocking" mode property on the cTcpClient object would be a nice addition though.

  28. #68

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    The RC6 cWebServer object uses a cTcpServer object under the hood. The cTcpServer object uses the SO_REUSEADDR socket option, and that means the bind will "succeed" no matter what (but then the behavior for all sockets bound to that port is indeterminate).

    Interesting article about SO_REUSEADDR here: https://docs.microsoft.com/en-us/win...clusiveaddruse Interesting snippet from that article:

    The exception to this non-deterministic behavior is multicast sockets. If two sockets are bound to the same interface and port and are members of the same multicast group, data will be delivered to both sockets, rather than an arbitrarily chosen one.

    ...

    The SO_REUSEADDR option has very few uses in normal applications aside from multicast sockets where data is delivered to all of the sockets bound on the same port. Otherwise, any application that sets this socket option should be redesigned to remove the dependency since it is eminently vulnerable to "socket hijacking". As long as SO_REUSEADDR socket option can be used to potentially hijack a port in a server application, the application must be considered to be not secure.
    At this point I'm a bit out of my depth, but maybe a cTcpServer option to use SO_EXCLUSIVEADDRUSE would be another useful addition to RC6? I defer to Olaf's expertise here.

  29. #69
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,654

    Re: VB6 Web Site/App Server

    Well I'll say this, in my experience writing normal Unicast Winsock applications in both VB6 and .Net, an error is supposed to be thrown when you try to listen on a port/IP combination that another server is already listening on locally. This is the behavior I expect and what I'm used to. Perhaps there is something going on here I'm not familiar with.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  30. #70
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,286

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    Interesting article about SO_REUSEADDR here: https://docs.microsoft.com/en-us/win...clusiveaddruse
    Yep, a bit further down the article even describes, why I've introduced the ReUse-Option:
    This issue can become complicated because the underlying transport protocol may not terminate the connection...
    It is possible that the underlying transport protocol might never release the connection


    At the time I've developed this (and used it intensively in different scenarios, with the RPCServer-Classes of the RichClient),
    having the ReUse-Option in place, ensured a much better "restart-behaviour" of the services.

    But this was in the era, where "XP/W2K" machines were common -
    perhaps such "hanging connections" (which can occur for all kind of reasons) -
    are detected by the modern OSes much earlier these days, so that a restart of such a Listener-Process -
    is not "doomed with constant failing" for longer time-intervals (as it was in the XP/W2k era).

    Quote Originally Posted by jpbro View Post
    At this point I'm a bit out of my depth, but maybe a cTcpServer option to use SO_EXCLUSIVEADDRUSE would be another useful addition to RC6? I defer to Olaf's expertise here.
    I could send you an early release of the RC6 (I'm still not yet done with the big one I've planned with the new SQLite-version) -
    in which I've switched the setsockopt-Call in the Listen-Method to SO_EXCLUSIVEADDRUSE instead of SO_REUSEADDR -
    (doing "two steps" forward, so to say).

    Olaf

  31. #71

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Schmidt View Post
    At the time I've developed this (and used it intensively in different scenarios, with the RPCServer-Classes of the RichClient),
    having the ReUse-Option in place, ensured a much better "restart-behaviour" of the services.

    But this was in the era, where "XP/W2K" machines were common -
    perhaps such "hanging connections" (which can occur for all kind of reasons) -
    are detected by the modern OSes much earlier these days, so that a restart of such a Listener-Process -
    is not "doomed with constant failing" for longer time-intervals (as it was in the XP/W2k era).
    Ah yes, that makes sense. Since the older OSes aren't being targeted by RC6 any more, I guess there shouldn't be any issue moving to the newer SO_EXCLUSIVEADDRUSE listen method.


    Quote Originally Posted by Schmidt View Post
    I could send you an early release of the RC6 (I'm still not yet done with the big one I've planned with the new SQLite-version) -
    in which I've switched the setsockopt-Call in the Listen-Method to SO_EXCLUSIVEADDRUSE instead of SO_REUSEADDR -
    (doing "two steps" forward, so to say).
    Thank you Olaf, but there's certainly no rush on my part. If you prefer to take your time to get the other big stuff done and release once, that's perfectly fine with me. Unless you would like me to test the SO_EXCLUSIVEADDRUSE change in case it might have some unintended side effects? I'm more than happy to do that, and I can even see how it goes under Linux/Wine.
    Last edited by jpbro; Jan 10th, 2022 at 06:03 PM.

  32. #72

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Niya View Post
    Well I'll say this, in my experience writing normal Unicast Winsock applications in both VB6 and .Net, an error is supposed to be thrown when you try to listen on a port/IP combination that another server is already listening on locally. This is the behavior I expect and what I'm used to. Perhaps there is something going on here I'm not familiar with.
    That was what I assumed would happen, but it looks like the SO_REUSEADDR method had different ideas

  33. #73

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    I've updated the source in the first post with the following changes:

    1) My "watchdog" code that monitors spawned listener/server processes was totally brain-dead (only testing if it could connect & send data, not checking to see if it could receive data). This should now be fixed.

    2) I've added a check to make sure the server ip/port that we are trying to bind to isn't already bound to another application. If it is, all app servers will be stopped. This is a stop gap measure while Olaf is working on the next RC6 release (which will use SO_EXCLUSIVEADDRUSE to bind to an adapter and fail if another app already is already bound as discussed here). Thank you for the prompt response Olaf!

  34. #74
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    162

    Re: VB6 Web Site/App Server

    Dear Sir,
    can you provide an a little example with calculator page?
    Just page with the texbox on it and with a button.
    And when we are typed in to the textbox any simple expression (like, 2+2), click the button, and the server return to page a result of our expression.
    Thank you very much!
    Ten Years After - 01 You Give Me Loving

  35. #75

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Here's a very simple example that will evaluate formulas entered into your browsers address bar at the "evaluate/" path.

    For example, if you go to https://127.0.0.1:8080/evaluate/24/(2/100), you will get a plain text response that looks like this:

    Code:
    Formula: 24/(2*100)
    Result: 0.12
    You will need to add the following code to the CApp class, after the "showcase/" block in the RespondToRequest event.

    Code:
          ElseIf po_Helpers.Regex.Test(po_Req.Url(urlsection_Path), "^evaluate/.+$", False) Then
             ' Found an "evaluate/" path. We will try to evaluate anything after the "evaluate/" part of the path.
             
             ' For example, visiting http://127.0.0.1:8080/evaluate/24*(2/100)
             
             ' Will return a text/plain response of:
             '    Formula: 24/(2*100)
             '    Result: 0.12
             
             Dim l_EvaluateResult As Variant
             Dim l_EvaluateError As String
             Dim l_EvaluateFormula As String
             
             ' Strip "evaluate/" from the start of the path to get the formual
             l_EvaluateFormula = Trim$(Mid$(po_Req.Url(urlsection_Path), Len("evaluate/") + 1))
             ' Strip trailing "/" if present in the formula to avoid division by 0 error
             If Right$(l_EvaluateFormula, 1) = "/" Then l_EvaluateFormula = Left$(l_EvaluateFormula, Len(l_EvaluateFormula) - 1)
             
             ' Attempt to evaluate the formula
             l_EvaluateResult = New_C.Formula.Evaluate(l_EvaluateFormula, l_EvaluateError)
             
             If l_EvaluateError <> vbNullString Then
                ' There was an error evaluating the formula! So set the result to the error.
                l_EvaluateResult = "*ERROR: " & l_EvaluateError
             End If
             
             ' Return the formula and the result as plain text.
             po_Response.SendSimplePlainTextResponse "Formula: " & l_EvaluateFormula & vbNewLine & "Result: " & l_EvaluateResult
    IMPORTANT NOTE:It looks like the RC6 cWebServer class won't accept "+" in your URL path formulas. So for testing purposes for now, only use "-", "*", "/", and parentheses to test different formula evaluations. If you want try addition, instead of "+", use "%2B" in your formula (that will get converted to + on the server side).

    Olaf - it looks like the URLDecode method always converts "+" to a space character, but I'm not sure that this is required? I tried a few online URLDecoders and some converted "+" to "-", but others didn't. A bit of research seems to indicate that "+" should be valid in URL paths, but possibly converted to " " in the query part of the URL. I take this to mean that a URL like this:

    Code:
    http://127.0.0.1:8080/evaluate/2+2?2+2
    Should be decoded to:

    Code:
    http://127.0.0.1:8080/evaluate/2+2?2 2
    That is, the first + in the path is left alone, but the second + in the query is converted to " ".

    I say "possibly" for the above, because none of the browsers I tried auto-converted "+" to "%2B" anywhere in the URL, which seems to indicate that + is legal anywhere in a URL. The exception would be for x-form-urlencoded data submitted from a form that *does* use "+" to indicate " ".

    I have to do a bit more research to be sure, but it does look like this has been a source of confusion in other languages/frameworks/etc...

    A thought: Perhaps URLDecode/URLEncode should only be for x-form-urlencoded queries, not for URL paths handled by the cWebRequest class. cWebRequest should have it's own URLDecoding that skips the "+" to " " conversion. Or perhaps, URLDecode could have an optional parameter (PreservePlus) that cWebRequest and other callers can set to TRUE when they know they are dealing with URLs and not form data?
    Last edited by jpbro; Jan 12th, 2022 at 10:25 PM.

  36. #76
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,286

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    ...it looks like the URLDecode method always converts "+" to a space character, but I'm not sure that this is required?
    Interpreting a "+" as WitheSpace-Char, still seems "standard-behaviour"...
    https://stackoverflow.com/questions/...ymbol-in-a-url

    I guess, if somebody wants to make his own Formula-parsing WebAPI-function,
    (passing the Formula in the URL), it is good advice, to perform (still at the clientside):
    FormulaParam = New_c.Crypt.UrlEncode(TheFormulaString)
    (or a javascript-equivalent, when triggered from a Browser).

    Or pass the Formula-Param JSON-encoded in the Body (using a POST-Request).

    Olaf

  37. #77

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Schmidt View Post
    Interpreting a "+" as WitheSpace-Char, still seems "standard-behaviour"...
    It does seem common, but I've tried some online URL decoders and not all convert + to " ".

    According to the URI spec at w3.org, "+" is reserved as a shorthand notation for " " only within the query string:

    Query strings
    The question mark ("?", ASCII 3F hex) is used to delimit the boundary between the URI of a queryable object, and a set of words used to express a query on that object. When this form is used, the combined URI stands for the object which results from the query being applied to the original object.

    Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This method was used to make query URIs easier to pass in systems which did not allow spaces.
    And according to RFC 3986 Appendix A, "+" is allowed in the scheme component of a URL:

    scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
    A naive +=" " approach would break the URL (in admittedly vanishingly small set of URLs in the real-world, though some surprisingly exist!).

    Here's an interesting ticket with a similar report of Java's URLDecode method unexpectedly converting "+" to " ". It was closed as "not an issue" not because URLDecode was correctly decoding URLs, but because the documentation stated it should only be used for HTML form encoding/decoding, nor for URL encoding (LOL - don't use URLDecode for decoding URLs)!

    The Java API documentation at https://docs.oracle.com/javase/8/doc...a/net/URL.html clearly states that "The URLEncoder and URLDecoder classes can also be used, but only for HTML form encoding, which is not the same as the encoding scheme defined in RFC2396." . This means that it is not meant for URL encoding and will cause issues with spaces and plus signs in the path.
    Quote Originally Posted by Schmidt View Post
    Or pass the Formula-Param JSON-encoded in the Body (using a POST-Request).
    Agreed that this is a better approach. My example using the URL was just a "quick and dirty" attempt to demonstrate how you can evaluate a formula, not a recommended way to do it. But I think it exposed a shortcoming in the cWebResponse class' URL decoding.

    If you don't want to change the cCrypt URLDecode method, because it may break existing code or because adding a new parameter will break binary compatibility, I understand completely. Would you instead consider one of the following two solutions:

    1) Implement a separate URLDecode method for the cWebResponse class (I'll email a modified cCrypt URLDecode that could be used to try and save you some time)

    OR

    2) Add a RawUrl property to the cWebRequest class so we can perform our own RFC-compliant decoding?

  38. #78
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,286

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post

    1) Implement a separate URLDecode method for the cWebResponse class (I'll email a modified cCrypt URLDecode that could be used to try and save you some time)

    OR

    2) Add a RawUrl property to the cWebRequest class so we can perform our own RFC-compliant decoding?
    Regarding 1):
    The next release will have the following changes in cCrypt, cWebRequest and cWebResponse
    (regading the UrlDecode Method-Signature, all using the same decoding-routine underneath):
    Public Function URLDecode(U As String, Optional ByVal PlusSignToSpace As Boolean = True) As String

    Meaning, that backward-compatibility is kept (the new Optional Param defaulting to True) -
    but one can influence the PlusSign-Decoding now...

    Regarding 2)
    The new optional Param then allows in conjunction with the new Property cWebRequest.URLRaw,
    a specific decoding (without rolling your own function), by using:
    MyDecodedURL = Request.URLDecode(Request.UrlRaw, False)

    HTH

    Olaf

  39. #79

    Thread Starter
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,466

    Re: VB6 Web Site/App Server

    Thank you Olaf, the new changes are very much appreciated!

  40. #80
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,225

    Re: VB6 Web Site/App Server

    IMO the query string should not be escaped/decoded. My observations are that WinHttp converts query strings to utf-8 and encodes every byte with highest bit set using %XY in hex to be able to "smuggle" headers through 7-bit networks probably (no idea actually).

    In WinHttpRequest object there are several options which control url *escaping* performed:

    - WinHttpRequestOption_UrlEscapeDisable (default False) - if set does not call UrlEscape API for URL at all (incl. query string)
    - WinHttpRequestOption_UrlEscapeDisableQuery (default True) - if set does not call UrlEscape API for query string only
    - WinHttpRequestOption_EscapePercentInURL (default false) - if set uses URL_ESCAPE_PERCENT flag in both calls to UrlEscape above

    After calls to UrlEscape always hex encodes bytes with high bit set (second/custom ANSI codepage) to %XY

    I think URLs are a big mess already, probably would be best to make possible to submit to the http server *any* Unicode string in the query string with high fidelity i.e. convert to utf-8 and don't massage/process it too much.

    For the first part of the URL all hope is lost already IMO, it's not possible to pass random Unicode strings so this is more restricted by design, more escaped as a consequence and more error prone (i.e. client requests something but server understands another path altogether is not uncommon).

    Best would be to make the http server compatible win WinHttpRequest but this would require a large test harness to encompass all the nasty corner-cases.

    cheers,
    </wqw>

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width