Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........
Started by aurelCB, June 06, 2010, 12:23:37 PM
0 Members and 1 Guest are viewing this topic.
QuoteIs there any idea how write one simple proxy program or maby someone have example for that?
GET http://www.ionicwind.com/ HTTP/1.0 <newline>Proxy-Connection: string <newline>Some-other-header: string <newline>Content-Length: integer <newline><newline>optional data goes here, Content-Length bytes
pointer buffer = new(char, 8192)pointer pos = bufferint BytesLeft = 8192 - 1 ' room for terminating NULLBOOL receiving = TRUEBOOL HeadersCompleted = FALSEwhile (receiving) int BytesReceived = recv(socket, pos, BytesLeft, 0) if (BytesReceived = -1) ' exit the loop - network error, connection closed (no more data). Call WSAGetLastError to check what is wrong. receiving = FALSE else pos += BytesReceived BytesLeft -= BytesReceived *<char>pos = 0 ' optional - cut off trash endif int nn = instr(*<string>buffer, "\n\n") if nn HeadersCompleted = TRUE ' here extract the url, find content-length, print to console ... endif if (!BytesLeft) ' todo: resize buffer endifwend