Overview
Comment: | Improve error handling with sockets. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
baad47ed5b287f5271c31ff871080f98 |
User & Date: | js on 2010-04-10 16:46:59 |
Other Links: | manifest | tags |
Context
2010-04-10
| ||
21:29 |
Greatly improve OFThread. This fixes a lot of issues that happened in the real world. check-in: ea96fd1e24 user: js tags: trunk | |
16:46 | Improve error handling with sockets. check-in: baad47ed5b user: js tags: trunk | |
16:13 | Add -[writeFormat:withArguments:] to OFStream. check-in: 948a5c25ce user: js tags: trunk | |
Changes
Modified src/OFExceptions.m from [b73f7f5e15] to [c18e0d43e4].
︙ | ︙ | |||
436 437 438 439 440 441 442 | - initWithClass: (Class)class__ size: (size_t)size { self = [super initWithClass: class__]; req_size = size; | | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | - initWithClass: (Class)class__ size: (size_t)size { self = [super initWithClass: class__]; req_size = size; if ([class__ isSubclassOfClass: [OFSocket class]]) err = GET_SOCK_ERR; else err = GET_ERR; return self; } |
︙ | ︙ |
Modified src/OFSocket.m from [3f6d8a7208] to [3aa367c99c].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * the packaging of this file. */ #include "config.h" #include <string.h> #include <fcntl.h> #ifndef _WIN32 # include <sys/types.h> # include <sys/socket.h> #endif #import "OFSocket.h" | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * the packaging of this file. */ #include "config.h" #include <string.h> #include <fcntl.h> #include <errno.h> #ifndef _WIN32 # include <sys/types.h> # include <sys/socket.h> #endif #import "OFSocket.h" |
︙ | ︙ | |||
51 52 53 54 55 56 57 | } - (size_t)_readNBytes: (size_t)size intoBuffer: (char*)buf { ssize_t ret; | | > > > | | > > > > | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | } - (size_t)_readNBytes: (size_t)size intoBuffer: (char*)buf { ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; if (eos) errno = ENOTCONN; if (eos || (ret = recv(sock, buf, size, 0)) < 0) @throw [OFReadFailedException newWithClass: isa size: size]; if (ret == 0) eos = YES; return ret; } - (size_t)_writeNBytes: (size_t)size fromBuffer: (const char*)buf { ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; if (eos) errno = ENOTCONN; if (eos || (ret = send(sock, buf, size, 0)) == -1) @throw [OFWriteFailedException newWithClass: isa size: size]; /* This is safe, as we already checked for -1 */ return ret; } |
︙ | ︙ |