]> err.no Git - sope/blob - sope-core/NGStreams/NGStreams/NGSocketProtocols.h
Id fixes
[sope] / sope-core / NGStreams / NGStreams / NGSocketProtocols.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __NGNet_NGSocketProtocols_H__
24 #define __NGNet_NGSocketProtocols_H__
25
26 #import <Foundation/NSObject.h>
27 #include <NGStreams/NGStreamProtocols.h>
28
29 @class NSException;
30
31 // addresses
32
33 @protocol NGSocketAddress < NSObject >
34
35 - (void *)internalAddressRepresentation;
36 - (int)addressRepresentationSize;
37 - (id)domain; // (a NGSocketDomain)
38
39 // needed by socket address factory:
40 - (id)initWithDomain:(id)_domain
41   internalRepresentation:(void *)_representation
42   size:(int)_length;
43
44 @end
45
46 // sockets
47
48 @protocol NGSocket < NSObject >
49
50 - (id<NGSocketAddress>)localAddress;
51 - (BOOL)bindToAddress:(id<NGSocketAddress>)_localAddress;
52 - (BOOL)close;
53
54 - (NSException *)lastException;
55
56 @end
57
58 // domains
59
60 @protocol NGSocketDomain < NSObject >
61
62 - (id<NGSocketAddress>)addressWithRepresentation:(void *)_data
63   size:(unsigned int)_size;
64
65 - (int)socketDomain;
66 - (int)addressRepresentationSize;
67 - (int)protocol;
68
69 // these two methods manage resources associated with addresses
70 // (primarily the files used for AF_LOCAL sockets)
71 - (BOOL)prepareAddress:(id<NGSocketAddress>)_address
72   forBindWithSocket:(id<NGSocket>)_socket;
73 - (BOOL)cleanupAddress:(id<NGSocketAddress>)_address
74   afterCloseOfSocket:(id<NGSocket>)_socket;
75
76 @end
77
78 // concrete sockets
79
80 @protocol NGActiveSocket < NGSocket, NGStream, NGByteSequenceStream >
81
82 - (BOOL)connectToAddress:(id<NGSocketAddress>)_address;
83 - (BOOL)shutdown;
84
85 - (BOOL)isConnected;
86
87 - (id<NGSocketAddress>)remoteAddress;
88
89 @end
90
91 @protocol NGPassiveSocket < NGSocket >
92
93 - (BOOL)listenWithBacklog:(int)_backlogSize;
94 - (id<NGActiveSocket>)accept;
95
96 @end
97
98 // packets
99
100 @protocol NGDatagramPacket < NSObject >
101
102 - (void)setSender:(id<NGSocketAddress>)_address;
103 - (id<NGSocketAddress>)sender;
104 - (void)setReceiver:(id<NGSocketAddress>)_address;
105 - (id<NGSocketAddress>)receiver;
106
107 - (NSData *)data;
108
109 @end
110
111 @protocol NGDatagramPacketFactory < NSObject >
112
113 - (id<NGDatagramPacket>)packetWithData:(NSData *)_data;
114
115 - (id<NGDatagramPacket>)
116   packetWithBytes:(const void *)_bytes
117   size:(int)_packetSize;
118
119 @end
120
121 #endif /* __NGNet_NGSocketProtocols_H__ */