I had been working on a project, the chain browser mentioned before, and i went back to polish up the socket portion of it. The problem i faced was i would get the right data back from a server but there would be a delay on the last recv() that slowed everything down to a crawl. Initially i discovered that id i put a Shutdown() after i sent the data i would get back the data quickly without that delay. But this was unpredictable because sometimes i wouldn't get anything. So i had to remove it to retain predictability. So after some more studying i learned about using select() to delay the program till there was data ready to recv(). However using select didn't really seem to do much and it wasn't till I added in ioctlsocket(FIONREAD) (or just ioctl() if your using Berkly sockets). the trick was putting the ioctlsocket() in the right spot. At first it would return 0 bytes which meant that there was 0 bytes ready to recv(), which wasn't accurate. the key is to wait with select till there is data available, then figure out how much with ioctlsocket(FIONREAD), and lastly recv() but only the amount of bytes you get from the ioctlsocket(). After playing around with it for a little it worked great about 99% of the time. The socket library is very well documented but how to use it all together isn't. Not to mention there are hundreds of different types of applications using sockets and they all using them differently. whats even worse is that protocols like http use sockets differently throughout the protocol itself.
Lastly i posted a a file, something like Socket.cpp and Socket.h for an example. if you have any questions just email me or leave a comment. also consider that those files are part of a larger project. While i haven't posted an up to date versoin of that project you should be able to plug the "socket files" into one of the other projects i have posted.
Showing posts with label HTTP/Socket. Show all posts
Showing posts with label HTTP/Socket. Show all posts
Thursday, September 11, 2008
Tuesday, September 9, 2008
Chain Browser, AutoBrowser, WebBrowsing made easy with "Botnets" and webcrawlers
This is something i have been working on for a bit and have been posting parts of on for while.
The concept for this project is... well let me back up and explain where the idea came from. Imagine that you check your email 10 times a day and you check your facebook 5 times a day. However both are only updated twice a day so you end up do a lot more checking then necessary. So imaging you have a browser that checks your sites for you and tells you how much has changed since you last checked yourself. this browser you also be able to do things that no current browser can do as well. For example say you wanted to request everyone to be your friend on facebook, well by using a conventional browser this would take forever but you would notice a pattern to how you request everyone. this would be easy for a program to do and quickly.
The concept for this project is... well let me back up and explain where the idea came from. Imagine that you check your email 10 times a day and you check your facebook 5 times a day. However both are only updated twice a day so you end up do a lot more checking then necessary. So imaging you have a browser that checks your sites for you and tells you how much has changed since you last checked yourself. this browser you also be able to do things that no current browser can do as well. For example say you wanted to request everyone to be your friend on facebook, well by using a conventional browser this would take forever but you would notice a pattern to how you request everyone. this would be easy for a program to do and quickly.
Tuesday, July 1, 2008
HTTP/Socket 2
I again updated the source for the HTTP/Socket "library" i will need for a few projects of mine. By the way for any readers that may have been noticing that the source for certain projects are being updated and changed and would like to see previous versions are more than welcome request them (and i wont turn down such a request).
The most notable addition is that the HTTP class is a part of a broader "webpage" class. the webpage class performs actions based on the response of the HTTP request; such as caching the cookies, and getting the page resources (like images). i also did some work on the foundation. I went back and improved the socket class, however there are still some issues.
The biggest issue I'm having and AM DYING FOR SOME FEEDBACK, is that after I've received all the data there is a waiting time/delay. I don't understand exactly what I'm doing wrong, as i would prefer to just send my data, receive the servers data and close the connection as quick as possible. I did some studying on the web and one answer i found was to use the "shutdown(socket,SD_SEND)" function. HOWEVER this seems to only 50% fix the problem because when using shutdown sometimes i receive 0 bytes back and worse yet its not consistent, so i conjecture as to what the exact problem is. ANY HELP WOULD BE HOT.
Anyway i would check out the source its not to shabby. The next step is going to be the cool one, but the one that will require the most precoding thinking/planning. The next step is to implment the interactions from one site to the next.
The most notable addition is that the HTTP class is a part of a broader "webpage" class. the webpage class performs actions based on the response of the HTTP request; such as caching the cookies, and getting the page resources (like images). i also did some work on the foundation. I went back and improved the socket class, however there are still some issues.
The biggest issue I'm having and AM DYING FOR SOME FEEDBACK, is that after I've received all the data there is a waiting time/delay. I don't understand exactly what I'm doing wrong, as i would prefer to just send my data, receive the servers data and close the connection as quick as possible. I did some studying on the web and one answer i found was to use the "shutdown(socket,SD_SEND)" function. HOWEVER this seems to only 50% fix the problem because when using shutdown sometimes i receive 0 bytes back and worse yet its not consistent, so i conjecture as to what the exact problem is. ANY HELP WOULD BE HOT.
Anyway i would check out the source its not to shabby. The next step is going to be the cool one, but the one that will require the most precoding thinking/planning. The next step is to implment the interactions from one site to the next.
Friday, June 13, 2008
HTTP/Socket 1
I finally posted updated source code for the HTTP and socket projects (particularly the web crawler). The code is pretty solid, i think there is a good amount of error handling... but i could be wrong and would appreciated being to sold (and why). It's late so I'm not going to describe what is going on in the code, just take a look for your self. I will, however, describe what it does/can do. It can send GET and POST requests to servers. In addition requests can be encrypted via ssl (i used openSSl so props to them). This means that you can GET and POST from servers using "HTTPS". One should also notice how easy it is to send requests. you pretty much need to define a URL as a string and then send it and you get the response back. Lastly i compiled this on DEV C++ and had to find a special DEV C++ package to get the ssl code to work. you can either head on over to the openSSL site and figure out what you need to do to make it work (it is document pretty well) or search around for the package, try this site.
Subscribe to:
Posts (Atom)