The main program, httpproxy.cpp, so far just makes the outgoing half of the connection:

int main(int argc, char* argv[])
{
  LSock_Startup();

  //  Make connection to other end

  LSOCK cli = LSock_Connect( "www.majestymagazine.com", 0, 80 );

  LSock_WriteLine( cli, "GET /images/issue/large.jpg HTTP/1.1" );
  LSock_WriteLine( cli, "Host: www.majestymagazine.com" );
  LSock_WriteLine( cli, "" );

  char linebuf[5000];

  do
  {
    LSock_ReadLine( cli, linebuf, 4096, true );
    printf( "%s\n", linebuf );
  }
  while( linebuf[0] != '\n' );

  LSock_CloseSocket(cli);

  LSock_Shutdown();

  return 0;
}

LSOCK

The notes at the top of lsock003.h:

LKS Sockets interface v0.03

LSOCK 0.04

TODO: Concurrency

LSOCK 0.03

Added data buffering to lsockets to enable more advanced blocking functions:

  LSock_ReadLine
    Reads up to a new line character
  LSock_ReadUpTo
    Reads up to a specified character pattern
  LSock_WriteLine
    Sends a buffer and then a newline character
  LSock_WriteString
    Sends a null-terminated string (without sending the null character)

TODO: Error checking everywhere
TODO: Check if there can be any concurrency problems...
TODO: Make GetSocketLocal and GetSocketRemote actually work!!
TODO: Make a GetSocketStats function
TODO: Make sure bytes_send and bytes_recv are updated everywhere they need to be.
TODO: SetSocketUserData and GetSocketUserData
TODO: Make the string searching function work properly! (eg. find "ab" in "aabb" would fail at the moment)

Made LSock_Startup and LSock_Shutdown call WSAStartup and WSACleanup.

LSOCK 0.02

  Basic lsocket functionality (blocking only)

LMEM

And at the top of lmem003.h, the handle-based storage LSOCK keeps its sockets in:

LMEM v0.03

TODO: Lots more error checking... :)  (ie. SOME)
TODO: Better main array than fixed 1024 entry one :)

LMEM v0.03

Added type:
  Heap

LMEM v0.02

Supported types:
  Lookup

LOOKUP

Stores DWORDS which can be accessed by handle.

Source 6 files