Differences From Artifact [c248fb563e]:
- File
src/OFStreamSocket.m
— part of check-in
[b4cd87cd81]
at
2017-05-21 23:57:34
on branch trunk
— Use closesocket() instead of close()
Previously, socket_helpers.h would just define close() to whatever is
needed to close a socket. However, this makes it possible to
accidentally call a socket-specific close on something that is not a
socket. Having to explicitly call closesocket() (and defining it to
close() on platforms where it's the same) prevents this. (user: js, size: 3980) [annotate] [blame] [check-ins using]
To Artifact [eec652ecb7]:
- File
src/OFStreamSocket.m
— part of check-in
[f9cd4f9cab]
at
2017-06-05 15:51:48
on branch trunk
— OFStream: Don't throw when at end of stream
Instead, let reads return 0 and let writes append after the end. (user: js, size: 3785) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | + (instancetype)socket { return [[[self alloc] init] autorelease]; } - (bool)lowlevelIsAtEndOfStream { return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; | > > > < < < < < | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | + (instancetype)socket { return [[[self alloc] init] autorelease]; } - (bool)lowlevelIsAtEndOfStream { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; return _atEndOfStream; } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_WINDOWS if ((ret = recv(_socket, buffer, length, 0)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; #else |
︙ | ︙ | |||
91 92 93 94 95 96 97 | - (void)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; | < < < < < | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | - (void)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; #ifndef OF_WINDOWS if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if (send(_socket, buffer, length, 0) != (ssize_t)length) @throw [OFWriteFailedException exceptionWithObject: self |
︙ | ︙ |