Home  +  Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Sockets~
~New~
~Examples~
~Contact~

C++ Socket library tutorial

Using HttpPutSocket

Prev   |   Menu   |   Next

Here is a short program that's using the HttpPutSocket class. After instantiating the socket, the program has to supply the filename to be sent and its content type.

put_demo.cpp
#include <StdoutLog.h>
#include <SocketHandler.h>
#include <HttpPutSocket.h>


int main(int argc,char *argv[])
{
	StdoutLog log;
	SocketHandler h(&log);
	HttpPutSocket sock( h, "https://www.myhost.bogus/index.html" );

	sock.SetFile( "~/myhost_html/index.html" );
	sock.SetContentType( "text/html" );

	sock.Open();
	h.Add(&sock);
	h.Select(1,0);
	while (h.GetCount())
	{
		h.Select(1,0);
	}

	printf("Status of operation: %s %s\n", sock.GetStatus().c_str(), sock.GetStatusText().c_str());

	return 0;
}



Prev   |   Menu   |   Next

Valid HTML 4.01!

Validate
Page, code, and content Copyright (C) 2021 by Anders Hedström