ObjFW  Artifact [53eb38c1df]

Artifact 53eb38c1df314d5b5a300645769b6289b4a12516b68c7c18cbbc3dfa1c13dd2a:


/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <string.h>

#import "OFSocket.h"
#import "OFExceptions.h"

const char *sendstr = "GET / HTTP/1.1\r\nHost: webkeks.org\r\n\r\n";

int
main()
{
	OFSocketAddress *addr;
	OFSocket *sock;

	@try {
		addr = [OFSocketAddress newWithHost: "webkeks.org"
					    andPort: 80
					  andFamily: AF_UNSPEC
					    andType: SOCK_STREAM
					andProtocol: 0];
		sock = [OFSocket new];
		[sock connect: addr];
		[addr free];

		[sock writeNBytes: strlen(sendstr)
		       fromBuffer: (uint8_t*)sendstr];

		puts((char*)[sock readNBytes: 1024]);

		[sock free];
	} @catch(OFException *e) {
		printf("EXCEPTION: %s\n", [e cString]);
	}

	return 0;
}