Differences From Artifact [94deb56f45]:
- File
src/OFTCPSocket.m
— part of check-in
[1404d33024]
at
2011-01-08 15:57:35
on branch trunk
— Ignore SIGPIPE when using OFStream.
SIGPIPE is quite useless and contraproductive as we throw an
OFWriteFailedException anyway. (user: js, size: 9273) [annotate] [blame] [check-ins using]
To Artifact [8771225ab8]:
- File src/OFTCPSocket.m — part of check-in [ca53d41c0f] at 2011-01-22 23:53:13 on branch trunk — Autodetect family in -[bindService:onNode:]. (user: js, size: 9030) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
197 198 199 200 201 202 203 | @throw [OFConnectionFailedException newWithClass: isa node: node service: service]; } - (void)bindService: (OFString*)service onNode: (OFString*)node | < < < < < < < < < < < < < < < | | < < | > > > > | < | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | @throw [OFConnectionFailedException newWithClass: isa node: node service: service]; } - (void)bindService: (OFString*)service onNode: (OFString*)node { if (sock != INVALID_SOCKET) @throw [OFAlreadyConnectedException newWithClass: isa]; #ifdef HAVE_THREADSAFE_GETADDRINFO struct addrinfo hints, *res; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if (getaddrinfo([node cString], [service cString], &hints, &res)) @throw [OFAddressTranslationFailedException newWithClass: isa node: node service: service]; if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET) @throw [OFBindFailedException newWithClass: isa node: node service: service]; if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) { freeaddrinfo(res); close(sock); sock = INVALID_SOCKET; @throw [OFBindFailedException newWithClass: isa node: node service: service]; } freeaddrinfo(res); #else struct hostent *he; struct servent *se; struct sockaddr_in addr; |
︙ | ︙ | |||
270 271 272 273 274 275 276 | if ((se = getservbyname([service cString], "TCP")) != NULL) port = se->s_port; else if ((port = OF_BSWAP16_IF_LE(strtol([service cString], NULL, 10))) == 0) { # ifdef OF_THREADS [mutex unlock]; # endif | < < < < > > > > | < | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | if ((se = getservbyname([service cString], "TCP")) != NULL) port = se->s_port; else if ((port = OF_BSWAP16_IF_LE(strtol([service cString], NULL, 10))) == 0) { # ifdef OF_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException newWithClass: isa node: node service: service]; } memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = port; if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) { # ifdef OF_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException newWithClass: isa node: node service: service]; } memcpy(&addr.sin_addr.s_addr, he->h_addr_list[0], he->h_length); # ifdef OF_THREADS [mutex unlock]; # endif if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) @throw [OFBindFailedException newWithClass: isa node: node service: service]; if (bind(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) { close(sock); sock = INVALID_SOCKET; @throw [OFBindFailedException newWithClass: isa node: node service: service]; } #endif } - (void)listenWithBackLog: (int)backlog { if (sock == INVALID_SOCKET) |
︙ | ︙ |