Sunday, February 20, 2011

Simple Multithreaded Web Server in Python



Like before when a client connects its socket it passed to the clientThread Class and then we call start which starts the thread

in the main loop of the thread instead of trying to pinpoint where the GET or POST request is i simply split the string by a space and then get the 2nd element(in this case its the 1st since we start at 0) is the file the client wants
so we take this file and get the extension of the file by spiting the file by the "." so that the 2nd elements(again starting at 0) so that we get the ext of the file requested now we can do a small check and see if they want a plain text/css/javascript file or a exe or image or anything else that would need to be opened with the binary mode right after that we close the socket and stop the while loop
so the client knows we are done sending the requested file.

Saturday, February 19, 2011

Win32 Api Usage using Ctypes


This utilizes the Ctypes library that allows you to use functions and methods from both Dlls and .so files in both the windows and *nix Operating system i assume it would also work in mac since its based on unix
This test simply uses the FindWindow Function with SetWindowText to change the title of the Window that was found.
This is great if you want to make alot of Api Calls but dont want to program in C just for the purpose of using windows api calls
for refrence on how to use the functions you should use msdn and search the function

Simple Multithreaded Echo Server in Python


This listens for connections comming in and for each client that connects
it spawns a thread for each client by passing in the socket that is created in the while loop to the clientThread class (that has a base Class of Thread)