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
49
50
|
#import <time.h>
#import <stdlib.h>
#import <string.h>
#import "OFTCPSocket.h"
#import "OFExceptions.h"
#ifndef _WIN32 /* FIXME */
inline uint16_t get_port()
{
uint16_t port = (uint16_t)random();
if (port < 1024)
port += 1024;
printf("Using port %d...\n", port);
return port;
}
#endif
int
main()
{
#ifndef _WIN32 /* FIXME */
uint16_t port;
srandom(time(NULL));
@try {
OFTCPSocket *server = [OFTCPSocket new];
OFTCPSocket *client = [OFTCPSocket new];
OFTCPSocket *accepted;
char buf[7];
puts("== IPv4 ==");
port = get_port();
|
<
|
<
<
|
>
>
|
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
49
|
#import <time.h>
#import <stdlib.h>
#import <string.h>
#import "OFTCPSocket.h"
#import "OFExceptions.h"
inline uint16_t get_port()
{
uint16_t port = (uint16_t)rand();
if (port < 1024)
port += 1024;
printf("Using port %d...\n", port);
return port;
}
int
main()
{
uint16_t port;
srand(time(NULL));
@try {
[OFTCPSocket startup];
OFTCPSocket *server = [OFTCPSocket new];
OFTCPSocket *client = [OFTCPSocket new];
OFTCPSocket *accepted;
char buf[7];
puts("== IPv4 ==");
port = get_port();
|
107
108
109
110
111
112
113
114
115
116
117
|
[accepted free];
[client free];
[server free];
} @catch(OFException *e) {
printf("EXCEPTION: %s\n", [e cString]);
return 1;
}
#endif
return 0;
}
|
<
|
106
107
108
109
110
111
112
113
114
115
|
[accepted free];
[client free];
[server free];
} @catch(OFException *e) {
printf("EXCEPTION: %s\n", [e cString]);
return 1;
}
return 0;
}
|