1
2
3
4
5
6
7
8
9
10
11
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
49
50
51
52
53
54
55
56
|
/*
* Copyright (c) 2008 - 2009
* 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.
*/
#include <stdio.h>
/*
* Headers for UNIX systems
*/
#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#endif
#import "OFStream.h"
/*
* Headers for Win32
*
* These must be imported after objc/Object and thus OFObject!
*/
#ifdef _WIN32
#define _WIN32_WINNT 0x0501
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
/**
* The OFTCPSocket class provides functions to create and use sockets.
*/
@interface OFTCPSocket: OFStream
{
#ifndef _WIN32
int sock;
#else
SOCKET sock;
#endif
struct sockaddr *saddr;
socklen_t saddr_len;
}
/**
* \return A new autoreleased OFTCPSocket
*/
+ tcpSocket;
/**
* Initializes an already allocated OFTCPSocket.
|
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/*
* Copyright (c) 2008 - 2009
* 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 "OFSocket.h"
/**
* The OFTCPSocket class provides functions to create and use sockets.
*/
@interface OFTCPSocket: OFSocket {}
/**
* \return A new autoreleased OFTCPSocket
*/
+ tcpSocket;
/**
* Initializes an already allocated OFTCPSocket.
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/**
* Accept an incoming connection.
* \return An autoreleased OFTCPSocket for the accepted connection.
*/
- (OFTCPSocket*)accept;
/**
* Enables/disables non-blocking I/O.
*/
- setBlocking: (BOOL)enable;
/**
* Enable or disable keep alives for the connection.
*/
- enableKeepAlives: (BOOL)enable;
/**
* Closes the socket.
*/
- close;
@end
|
<
<
<
<
<
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/**
* Accept an incoming connection.
* \return An autoreleased OFTCPSocket for the accepted connection.
*/
- (OFTCPSocket*)accept;
/**
* Enable or disable keep alives for the connection.
*/
- enableKeepAlives: (BOOL)enable;
/**
* Closes the socket.
*/
- close;
@end
|