FASt Server - Win32 Socket Library and Tutorial ....

Started by James Ladd, January 15, 2005, 02:41:51 AM

Previous topic - Next topic

James Ladd

All,

Thankyou for your interest in FAStServer and FAStUtils.
I will be working on them today and hope to address most of the issues raised.

I have a plan for what Im doing so that all can know what will be happening.

1. Continue with some FAStUtil stuff as its needed by the Echo plugin.
2. Update FASt Server so that the Echo pluging receives the read data and then posts the echo back. It needs a FASt Util for this to be done properly.
3. Update Echo to send a greeting message.
4. Enable the console handler so Ctrl-C shuts down the server gracefully. Currently this wasnt as important as getting the server to run.
5. Modify FAStServer to accept multiple connection and to scavenger and remove hanging connections.
    Again, FASt Util is needed for this.
6. Add pooling of IO worker threads. Currently there is only one for the purposes of getting the code running.
7. Re-package the code. There is to be a FAStSvr.exe and a FAStSvr.dll so you can run the server or use the DLL in your own projects.
8. Put together some configuration changes so the plugin can influence the FAStServer startup. Not just the listen port but things like
    buffer sizes and counts. There is a lot that can be done to tune FAStSvr for incredible IO.
9. Make a FAStClient that enables the client side of what FAStServer provides.
10. Fix bugs and other issues raised along the way. This will be ongoing during the duration of the project.

The main idea is to get a plugin working a.s.a.p so that people can write them. If the core FAStServer changes then this should
not effect the plugin. So potentially the FAStServer could be entirely re-written and the Plugin wouldnt know.
Over time there will be improvements to FAStServer and I dont want these to effect the plugin developer.

I would like to fix the DLL issues immediately but I dont have the facilities. If you are able to help in this area then I will make
sure the site is updates with the information and your details so people know you helped.

I hope the above is ok for all ?
This plan is also outlined on www.jamesladdcode.com

BTW - Mark - What are the files you have supplied and what do they do ?

Rgs, striker.

Petroizki

Just something i noticed while going trough the code:
       zero:
            cmp overlapped, 0
            jmp main_io_worker_loop_seriously_wrong ; <- should be 'je' ?

            ; todo: close the socket.
            jmp main_io_worker_loop


You know you could also replace all 'cmp eax, 0' with 'test eax, eax'..  :wink

James Ladd

Petroizki ,
Thanks for the pointers. I have made the change and the next version uploaded will contain the fix.
Also, does 'test eax, eax' have any advantages over 'cmp eax, 0' as I like to be consistent and if I
need to test for something other than '0', I can just write that value. Eg:   'cmp eax, 32'
rgs, striker

Petroizki

It's one byte smaller, and probably not so important, but i just like to mess with the little things, sorry.. :red

James Ladd

Petroizki ,

I appreciate the information. You never know when I want the code 1 byte smaller :)
Any other suggestions are welcomed too.

New update to FAStUtils and tomorrow or later tonight Ill integrate some of it into FAStServer

Rgs, striker

Mark Jones

 James, the .wap files are WinASM project files - see www.winasm.net.
For a WinASM screenshot with my funky dark color scheme (and the code library add-in running), Click Here.

Edit: attached is a client .ico file. Feel free to use (or not use) these files. :)

[attachment deleted by admin]
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Robert Collins

Quote from: striker on May 28, 2005, 05:09:52 AM
....does 'test eax, eax' have any advantages over 'cmp eax, 0'....

Not knowing for sure but based on my knowledge of another assembly language, the cmp eax,0 is a register to immediate value (meaning it occupies storage) instruction while test eax,eax is register only instruction therefore probably faster.

JohnJohn

Hi, good work with your project. I don't know much about assembly - still learning - but let me give my opinion about threads in this project. Since web servers and whatnot are mostly IO bound and not processor bound wouldn't it be better to use green/user threads instead of operating system threads? I found i get much better performance using user threads.

Keep up the good work.

hutch--

James,

Here is the reference from the Intel optimisation manual with preference for TEST over CMP.

Quote
Compares
Use test when comparing a value in a register with zero. Test essentially ands the
operands together without writing to a destination register. Test is preferred over and
because and produces an extra result register. Test is better than cmp ..., 0 because
the instruction size is smaller.
Use test when comparing the result of a logical and with an immediate constant for
equality or inequality if the register is eax for cases such as:
if (avar & 8) { }
The test instruction can also be used to detect rollover of modulo a power of 2. For
example, the C code:
if ( (avar % 16) == 0 ) { }
can be implemented using:
test eax, 0x0F
jnz AfterIf
Assembly/Compiler Coding Rule 50. (ML impact, M generality) Use the test instruction
instead of and or cmp if possible.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

James Ladd

JohnJohn,
Winsock 2 under the covers will use OS threads for managing IO completion ports. However, the threads used in
FAStServer could be green threads. I will look into this when the server is working properly and other things
dont need doing. Thanks for the suggestions.

Hutch,
Guess who will change things to use "test" ;)

James Ladd

#115
Stand by for an update with all the goodies in it coming very soon !

Anyone excited ?    .... anyone ?

Mark Jones

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

James Ladd

its coming, I just wanted to make sure someone was excited to see it when it gets here.
Not long now - promise.

Homer

I've posted an oop-based variant of your source (yesterday, on the other board).
Today I will diverge.

James Ladd

Homer,
Thanks.
I think the currenty source is rather crappy really. Im going to post another soon.
This version will be more feature packed, complete and better coded.
Im sure there are 100s here who can make better assembler. Im interested in
their/your feedback on the code.
Rgs, striker.