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
|
#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)random();
if (port < 1024)
port += 1024;
printf("Using port %d...\n", port);
return port;
}
int
main()
{
uint16_t port;
srandom(time(NULL));
@try {
OFTCPSocket *server = [OFTCPSocket new];
OFTCPSocket *client = [OFTCPSocket new];
|
>
>
>
|
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 <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];
|
104
105
106
107
108
109
110
111
112
113
|
[accepted free];
[client free];
[server free];
} @catch(OFException *e) {
printf("EXCEPTION: %s\n", [e cString]);
return 1;
}
return 0;
}
|
>
|
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;
}
|