12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#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;
}
|
<
<
|
<
|
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#import "config.h"
#import <string.h>
#import "OFSocket.h"
#import "OFExceptions.h"
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 writeCString: "GET / HTTP/1.1\r\n"
"Host: webkeks.org\r\n\r\n"];
puts((char*)[sock readNBytes: 1024]);
[sock free];
} @catch(OFException *e) {
printf("EXCEPTION: %s\n", [e cString]);
}
return 0;
}
|