101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#endif
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyAppleTalk;
address.length = (socklen_t)sizeof(address.sockaddr);
if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
|
|
|
|
|
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#endif
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: _OFSocketErrNo()];
_canBlock = true;
#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
if ((flags = fcntl(_socket, F_GETFD, 0)) != -1)
fcntl(_socket, F_SETFD, flags | FD_CLOEXEC);
#endif
if (bind(_socket, (struct sockaddr *)&address.sockaddr,
address.length) != 0) {
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: errNo];
}
memset(&address, 0, sizeof(address));
address.family = OFSocketAddressFamilyAppleTalk;
address.length = (socklen_t)sizeof(address.sockaddr);
if (_OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr,
&address.length) != 0) {
int errNo = _OFSocketErrNo();
closesocket(_socket);
_socket = OFInvalidSocketHandle;
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
struct ATInterfaceConfig), &config) != 0)
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: OFSocketErrNo()];
OFSocketAddressSetAppleTalkNetwork(&address, config.address.s_net);
OFSocketAddressSetAppleTalkNode(&address, config.address.s_node);
#endif
#if !defined(OF_MACOS) && !defined(OF_WINDOWS)
_protocolType = protocolType;
|
|
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
struct ATInterfaceConfig), &config) != 0)
@throw [OFBindDDPSocketFailedException
exceptionWithNetwork: network
node: node
port: port
protocolType: protocolType
socket: self
errNo: _OFSocketErrNo()];
OFSocketAddressSetAppleTalkNetwork(&address, config.address.s_net);
OFSocketAddressSetAppleTalkNode(&address, config.address.s_node);
#endif
#if !defined(OF_MACOS) && !defined(OF_WINDOWS)
_protocolType = protocolType;
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if ((ret = recvmsg(_socket, &msg, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: OFSocketErrNo()];
if (ret < 1 || protocolType != _protocolType)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length
errNo: ENOMSG];
if (sender != NULL) {
|
|
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
if (_socket == OFInvalidSocketHandle)
@throw [OFNotOpenException exceptionWithObject: self];
if ((ret = recvmsg(_socket, &msg, 0)) < 0)
@throw [OFReadFailedException
exceptionWithObject: self
requestedLength: length
errNo: _OFSocketErrNo()];
if (ret < 1 || protocolType != _protocolType)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length
errNo: ENOMSG];
if (sender != NULL) {
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
@throw [OFNotOpenException exceptionWithObject: self];
if ((bytesWritten = sendmsg(_socket, &msg, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: OFSocketErrNo()];
if ((size_t)bytesWritten != length + 1) {
bytesWritten--;
if (bytesWritten < 0)
bytesWritten = 0;
|
|
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
@throw [OFNotOpenException exceptionWithObject: self];
if ((bytesWritten = sendmsg(_socket, &msg, 0)) < 0)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
bytesWritten: 0
errNo: _OFSocketErrNo()];
if ((size_t)bytesWritten != length + 1) {
bytesWritten--;
if (bytesWritten < 0)
bytesWritten = 0;
|