ObjFW  History of src/OFStreamSocket.m of ffb91daffe96f478

History of file src/OFStreamSocket.m at check-in ffb91daffe96f478

2025-01-01
12:58
Update copyright file: [964bef97b8] check-in: [9d802a786d] user: js branch: trunk, size: 10822
2024-10-27
17:59
OFStreamSocket: Rework blocks-based API file: [0c4a622463] check-in: [34b4d743ad] user: js branch: trunk, size: 10822
16:14
OFSequencedPacketSocket: Rework blocks-based API file: [b741fa5166] check-in: [776202396c] user: js branch: trunk, size: 10124
2024-08-21
20:14
Make ObjFW compile on macOS/PowerPC 64 file: [5f7f7d637a] check-in: [7b0cd744dc] user: js branch: trunk, size: 10110
2024-08-17
17:30
Delay socket initialization as long as possible

On game consoles, initializing sockets takes a significant amount of
time. When not delaying socket initializing, that time is spent during
startup even when the application might never use sockets.

Worse yet, on Amiga, sockets might not be available at all and the
application will fail to start up, even when the application might never
use sockets. file: [6bb8a2cf49] check-in: [7460d2ccd8] user: js branch: trunk, size: 10099

09:51
Move private functions into private headers file: [53c37659e0] check-in: [b829f3e798] user: js branch: trunk, size: 10161
2024-04-29
21:42
Properly hide private symbols file: [83fbf8313f] check-in: [f16bccc7b3] user: js branch: trunk, size: 10140
2024-04-03
02:16
Change license to LGPLv3 only file: [a8d59e0323] check-in: [7413a728a7] user: js branch: trunk, size: 10129
2024-04-01
15:59
Remove #define __NO_EXT_QNX

It doesn't seem to be needed anymore. file: [a2d2d261a8] check-in: [cf0effe834] user: js branch: trunk, size: 9921

2024-01-02
17:17
Update copyright file: [f9f8a407eb] check-in: [26ddd2e4e4] user: js branch: trunk, size: 9942
2023-08-02
18:55
Work around MorphOS missing UNIQUE_ID file: [cfdeffc17d] check-in: [ffb2792718] user: js branch: trunk, size: 9942
18:12
Support moving sockets between threads on AmigaOS file: [3fe9c63f07] check-in: [983342d8dd] user: js branch: trunk, size: 9865
2023-02-11
23:49
OFStreamSocket: Require open socket in -[accept] file: [0cffca82b0] check-in: [c02886307e] user: js branch: trunk, size: 8668
2023-01-06
09:04
Update copyright file: [5e77bcfd73] check-in: [8939cbdb52] user: js branch: trunk, size: 8562
2022-11-16
01:27
Add OFAssert()

This uses the same format as OFEnsure(). file: [21ea0af8b5] check-in: [c86b8f10f0] user: js branch: trunk, size: 8562

2022-10-22
17:40
Rename OFListen{ -> OnSocket}FailedException file: [efe4f02a49] check-in: [df7f59b26c] user: js branch: trunk, size: 8580
16:53
Rename OFAccept{ -> Socket}FailedException file: [bfc59db558] check-in: [e171cfe7e5] user: js branch: trunk, size: 8564
2022-08-06
21:14
Don't use struct sockaddr in OFSocketAddress

struct sockaddr can contain a variable length array, which breaks the
union. file: [6c817945cd] check-in: [25adea9a23] user: js branch: trunk, size: 8540

14:43
Reorder node and network of IPX sockets

This is more standard, albeit -[connectToNetwork:node:port:] sounding a
little bit more like you connect to a network rather than a node. file: [aac8571961] check-in: [ccc6a77c55] user: js branch: trunk, size: 8489

2022-02-12
07:46
Update copyright file: [f14a71e66a] check-in: [1a86b8175b] user: js branch: trunk, size: 8489
2021-10-24
21:15
Add OFUNIXStreamSocket file: [79180ccd72] check-in: [aaf477fc88] user: js branch: unix-sockets, size: 8489
2021-05-08
19:30
Fix setCanBlock: being inverted on Windows/AmigaOS file: [5b9cb9181f] check-in: [91131d6d7d] user: js branch: trunk, size: 8369
2021-04-18
23:18
INVALID_SOCKET -> OFInvalidSocketHandle file: [a955b9500f] check-in: [4b587c8874] user: js branch: new-naming-convention, size: 8367
22:56
Rename all symbols marked extern file: [0813befdb2] check-in: [e73c65a849] user: js branch: new-naming-convention, size: 8264
20:51
Rename everything in several smaller files file: [5c58a6db92] check-in: [35de667566] user: js branch: new-naming-convention, size: 8286
2021-04-17
13:58
of_socket_address_t -> OFSocketAddress file: [3262c13b9d] check-in: [e3c5bb70dd] user: js branch: new-naming-convention, size: 8285
03:37
of_run_loop_mode_t -> OFRunLoopMode file: [81e1bbc5f7] check-in: [b480ef54db] user: js branch: new-naming-convention, size: 8311
03:21
Rename all blocks file: [ac4dcd7238] check-in: [c4e0e56fa3] user: js branch: new-naming-convention, size: 8336
2021-03-07
20:25
*.m: Fold methods into one line where it fits file: [7f5d88caa9] check-in: [1b82d3bf4f] user: js branch: trunk, size: 8350
2021-01-14
02:29
Define _HPUX_ALT_XOPEN_SOCKET_API where necessary

There is a nasty bug in HP-UX: When using the proper socket APIs that
take a socklen_t (which is 64 bit in LP64 mode), it still calls into
methods that expect an int - so there is a type mismatch between the
headers and the compiled system libraries. This leads to all socklen_t
being interpreted as 0 (due to big endian). Defining
_HPUX_ALT_XOPEN_SOCKET_API makes it use the correct symbols in the
system libraries instead. file: [791405f855] check-in: [1833194867] user: js branch: trunk, size: 8364

2021-01-13
23:01
Wrap _XOPEN_SOURCE_EXTENDED define in #ifndef file: [731a6e9d3a] check-in: [430d54e2a9] user: js branch: trunk, size: 8329
19:16
Define _XOPEN_SOURCE_EXTENDED where necessary file: [66cf0a873d] check-in: [d55b73f38e] user: js branch: trunk, size: 8290
2021-01-02
22:04
Update copyright file: [37c1cc3f6d] check-in: [374e1a1bfa] user: js branch: trunk, size: 8259
2020-05-06
00:32
Improve names of several properties file: [2df2daa037] check-in: [bc67e98833] user: js branch: trunk, size: 8348
2020-04-26
18:10
Move accept and listen OF{TCP -> Stream}Socket file: [1b3aa72b95] check-in: [13a8f43898] user: js branch: trunk, size: 8340
16:21
Add OFSequencedPacketSocket

This is intended for SCTP and SPX. file: [53952137a2] check-in: [e5b2ee56ff] user: js branch: trunk, size: 4323

2020-04-25
17:05
Add OFDatagramSocket as base class for OFUDPSocket

This makes it easier to reuse code for other datagram sockets, namely
IPX. file: [3d9d6aa117] check-in: [b02c4b05bb] user: js branch: trunk, size: 4333

2020-01-12
16:22
Cancel async requests in OFStreamSocket instead

Closing them in OFStream would result in always canceling them after
closing the socket due to the -[close] chaining - which could never
work. file: [6026b8fcfc] check-in: [cea3f2133d] user: js branch: trunk, size: 4136

2020-01-02
01:51
Update copyright file: [bc21bce60d] check-in: [c7f0229795] user: js branch: trunk, size: 4076
2019-08-09
23:44
Support sockets on AmigaOS 3 file: [d9c06730da] check-in: [3dec8ecf2e] user: js branch: trunk, size: 4073
2019-06-26
20:38
Fix non-blocking sockets on MorphOS file: [f3b8b9f100] check-in: [d1d1843970] user: js branch: trunk, size: 4065
2019-01-03
19:13
Update copyright file: [0652ea9722] check-in: [0509d7a844] user: js branch: trunk, size: 3984
2018-08-04
16:23
Support for non-blocking UDP sockets file: [8a940fe4f3] check-in: [7de9d67be9] user: js branch: trunk, size: 3978
2018-01-03
19:49
Update copyright notice file: [0965d972e9] check-in: [7e5c81e186] user: js branch: trunk, size: 5371
2017-11-19
12:56
Fix compilation with GCC file: [de7c76a291] check-in: [615a9f2eba] user: js branch: trunk, size: 5348
2017-09-24
12:24
OFStream: Add support for async writes file: [c5ebdea8f5] check-in: [481225349f] user: js branch: trunk, size: 3916
2017-06-12
22:29
OFWriteFailedException: Add -[bytesWritten]

This allows retrieving the number of bytes already written before the
write failed, allowing to retry without writing data that has already
been written. file: [272212f745] check-in: [2ae01218ef] user: js branch: trunk, size: 4073

2017-06-05
15:51
OFStream: Don't throw when at end of stream

Instead, let reads return 0 and let writes append after the end. file: [eec652ecb7] check-in: [f9cd4f9cab] user: js branch: trunk, size: 3785

2017-05-21
23:57
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. file: [c248fb563e] check-in: [b4cd87cd81] user: js branch: trunk, size: 3980

2017-05-07
20:10
Small code style change

Casts are now written like types in variable declarations. file: [d2e763431e] check-in: [4af49a13c3] user: js branch: trunk, size: 3974

2017-01-09
17:36
Update copyright

Forgot to add 2017, even though I already did quite some changes in
2017. file: [196ec0c55f] check-in: [44f45c2e35] user: js branch: trunk, size: 3972

2016-06-07
22:56
Add support for reusing OFStreams after close

Right now, this is only useful for OFTCPSocket, as this is the only
class so far not establishing the stream in the init method. However,
this adds the general infrastructure to allow reuse to all subclasses of
OFStream. file: [77a66a4df1] check-in: [1de551cb5f] user: js branch: trunk, size: 3966

2016-01-03
00:43
Update copyright

While at it, also update the mail address. file: [b0d72b729b] check-in: [cec0f072f8] user: js branch: 0.8, size: 3929

00:41
Update copyright

While at it, also update the mail address. file: [3021941e31] check-in: [2a27cf3000] user: js branch: trunk, size: 3949

2015-10-19
22:15
Add platform.h & make platform defines consistent file: [5d34917197] check-in: [1ba08eebc5] user: js branch: trunk, size: 3945
2015-10-04
11:30
Better length checks for write / send calls file: [5f9b6a238d] check-in: [fc73801932] user: js branch: trunk, size: 3925
2015-05-06
20:18
OFNotConnectedException -> OFNotOpenException file: [d996f514e3] check-in: [ff759684e2] user: js branch: trunk, size: 3849
2015-03-22
11:42
Abstract int vs SOCKET as of_socket_t file: [2a1777ff58] check-in: [099e939079] user: js branch: trunk, size: 3869
2015-02-16
08:39
Explicitly pass errno to exceptions

The old behaviour where the exception would access errno directly on
creation of the exception was very fragile. The two main problems with
it were that sometimes it would pick up an errno even though none had
been set and in other cases that when the exception was created errno
had already been overridden.

This also greatly increases errno handling on Win32, especially in
conjunction with sockets. It can still be improved further, though. file: [c547367b26] check-in: [62e2de30b9] user: js branch: trunk, size: 3777

2015-01-03
20:57
Update copyright file: [70d50e1c9d] check-in: [cfd374b906] user: js branch: trunk, size: 3697
2014-04-26
00:40
Fix a few issues on LLP64 and Win64

LLP64 was mostly fast enumeration using an unsigned long for the state,
which can't store a pointer or a size_t on LLP64. This is now solved by
either throwing an OFOutOfRangeException if the value of the size_t is
bigger than ULONG_MAX or storing the pointer in the extra field (copied
using memcpy, as it's an array of unsigned long, which again would be
too small to store a pointer).

Win64 was mostly Microsoft not being able to decide whether a length is
a size_t, a DWORD, an int or an unsigned int (thus the different types
in places that seem to be almost the same). But since that would not be
confusing enough, a file descriptor is an int if it's for a file, but a
long long if it is for a socket. But of course, for ReadFile and friends
it's a DWORD instead of an int then. file: [43c1e24000] check-in: [4e59d2692f] user: js branch: trunk, size: 3691

2014-02-18
00:22
Move around a few defines to be more consistent file: [8ed3399f44] check-in: [f9d12201f8] user: js branch: trunk, size: 2912
2014-02-03
14:43
Move socket initialization to a single place file: [917f870ee4] check-in: [414c87ec13] user: js branch: trunk, size: 2912
2014-01-26
13:32
Include unistd.h in socket_helpers.h file: [0ca4a3134a] check-in: [32ad39007a] user: js branch: trunk, size: 3108
2014-01-25
19:33
Move socket includes and helpers to separate files

The new file socket.h includes all headers required for sockets on the
used platform, while the file socket_helpers.h defines the BSD API
functions to the platform specific functions if necessary.

This cleans up the classes dealing with sockets a lot and also reduces
code duplication. file: [c2425f91c0] check-in: [81d47f4398] user: js branch: trunk, size: 3129

17:39
Generalize stream / socket related exceptions

This is in preparation for adding UDP sockets, as UDP sockets and TCP
sockets have no common superclass, as one is stream-oriented while the
other is packet-oriented.

Read and write exceptions are for any object now, as they are useful for
a lot more than just for streams, while the others (bind, listen, etc.)
are for any socket now (the type is id in this case, though, as there is
no common superclass). file: [5b827e504d] check-in: [8d2a5052fd] user: js branch: trunk, size: 3523

2014-01-04
00:24
Update copyright. file: [42d45e3daf] check-in: [3b97fc3cd9] user: js branch: trunk, size: 3523
2013-06-28
18:48
OFHTTPClient: Only retry on ECONNRESET or EPIPE. file: [e9adb99946] check-in: [e0182a3e55] user: js branch: trunk, size: 3517
2013-06-22
12:12
Rework exceptions.

This mostly removes the argument for the class in which the exception
occurred. As backtraces were recently added for all platforms, the
passed class does not give any extra information on where the exception
occurred anymore.

This also removes a few other arguments which were not too helpful. In
the past, the idea was to pass as many arguments as possible so that it
is easier to find the origin of the exception. However, as backtraces
are a much better way to find the origin, those are not useful anymore
and just make the exception more cumbersome to use. The rule is now to
only pass arguments that might help in recovering from the exception or
provide information that is otherwise not easily accessible. file: [252939c90a] check-in: [3d16a30f41] user: js branch: trunk, size: 3629

2013-06-11
23:33
Initial sockets support for the Wii.

Not functional yet due to bugs in the SDK.
Bugs found so far:

* Binding to port 0 fails instead of choosing a free port.
* gethostbyname() does not work for IPs.
* getsockname() is missing.
* struct sockaddr_storage is missing.

I have not decided yet whether I fix those bugs in the SDK (I already
implemented getsockname() and added struct sockaddr_stroage and it seems
to work) or if I work around them in ObjFW. This will mainly depend on
how cooperative the developers of the Wii SDK are. file: [10e23bfd72] check-in: [ffb91daffe] user: js branch: trunk, size: 3874

2013-05-22
18:42
Check for more socket-related headers / functions. file: [05982c597a] check-in: [896084c340] user: js branch: trunk, size: 3509
2013-04-07
21:21
Fix Win32 #include hell. file: [f99014d0c7] check-in: [ec6b265428] user: js branch: trunk, size: 3542
2013-03-04
17:20
Replace BOOL with bool.

The only places where BOOL is left are those where they are required by
the ABI. file: [9ccd3888ba] check-in: [c5ef582958] user: js branch: trunk, size: 3497

2013-02-12
18:22
Prefix all ivars with an underscore. file: [a7e950a736] check-in: [e40729d406] user: js branch: trunk, size: 3493
2013-01-09
22:24
Update copyright. file: [902270c256] check-in: [813c00ccf0] user: js branch: trunk, size: 3450
2012-10-09
15:07
Make use of instancetype. file: [ccc1ba2bd0] check-in: [fb515e8e24] user: js branch: trunk, size: 3444
2012-09-16
15:43
OFStream: Use lowlevel as prefix instead of _. file: [b406096bcb] check-in: [61c1932caf] user: js branch: trunk, size: 3430
2012-09-12
17:27
Split -[OFStream fileDescriptor].

It is now -[fileDescriptorForReading] and -[fileDescriptorForWriting].
The split was necessary as some stream types (e.g. OFProcess) don't have
a single file descriptor, but two. This allows to use those stream types
with OFStreamObserver as well. file: [fbc78fae5c] check-in: [440e95fd4a] user: js branch: trunk, size: 3409

2012-07-12
01:28
Don't access isa directly. file: [987460de9d] check-in: [8892ae9fcc] user: js branch: trunk, size: 3348
2012-06-07
12:03
Rework OFStream API. file: [57d59bfcb8] check-in: [0d4059306a] user: js branch: trunk, size: 3280
2012-01-05
00:56
Update copyright. file: [acbc1571b5] check-in: [ce70e17b38] user: js branch: trunk, size: 3279
2011-09-22
23:25
Exceptions are now autoreleased.

This is safe as an "exception loop" can't happen, since if allocating
an exception fails, it throws an OFAllocFailedException which is
preallocated and can always be thrown.

So, the worst case would be that an autorelease of an exception fails,
triggering an OFOutOfMemoryException for which there is no memory,
resulting in an OFAllocFailedException to be thrown. file: [45578e9a1c] check-in: [e1e7ffa903] user: js branch: trunk, size: 3273

2011-09-19
12:34
BOOL naming conventions. file: [dffe75edba] check-in: [d43eb177bc] user: js branch: trunk, size: 3197
2011-09-10
18:36
Remove -[finalize] as ARC will be implemented instead of a GC. file: [35ae964d9d] check-in: [972a3ee40d] user: js branch: trunk, size: 3209
2011-07-17
01:55
Define __NO_EXT_QNX in files using unistd.h or fcntl.h.

Without this, the headers try to declare functions that use __block as
an argument name and thus fail to compile when using -fblocks. file: [49fed451d1] check-in: [59e52af26d] user: js branch: 0.5, size: 3159

01:55
Define __NO_EXT_QNX in files using unistd.h or fcntl.h.

Without this, the headers try to declare functions that use __block as
an argument name and thus fail to compile when using -fblocks. file: [73e9748565] check-in: [da2701ad14] user: js branch: trunk, size: 3296

2011-06-20
19:26
Let -[writeNBytes:fromBuffer:] return void. file: [8d5170a63f] check-in: [2a2d5c4c47] user: js branch: trunk, size: 3272
2011-06-16
02:33
-[readNBytes:intoBuffer:] & -[writeNBytes:fromBuffer:] take a void* now. file: [a6c16a5220] check-in: [8440a70457] user: js branch: trunk, size: 3310
2011-04-24
21:50
Add -[finalize] to all classes which would require it once we have GC. file: [a5c51abdbf] check-in: [07b3d0e8de] user: js branch: trunk, size: 3310
2011-04-22
20:19
More style improvements. file: [773bb7067f] check-in: [e76a7f52c1] user: js branch: trunk, size: 3223
18:00
More style improvements. file: [7c915a3b62] check-in: [4814266280] user: js branch: trunk, size: 3265
2011-04-06
18:30
Move ivar listening to OFTCPSocket.
Also, we don't need these ivars to be @public anymore.
file: [f8648491b3] check-in: [d776cbf5e2] user: js branch: trunk, size: 3135
2011-03-30
00:03
A few win32 fixes. file: [2a532fea1c] check-in: [13a4dee1da] user: js branch: trunk, size: 3152
2011-03-28
23:54
One more workaround for a bug in gcc 4.4.4 (possibly only Haiku). file: [24f92d1402] check-in: [12dd2db6ce] user: js branch: trunk, size: 3071
2011-03-24
21:17
Pass the stream for stream exceptions. file: [e1ff8d6e4c] check-in: [7ced2e7b6a] user: js branch: trunk, size: 3121
20:36
Pass the socket for socket exceptions. file: [60c85e14ca] check-in: [a8df2cff5f] user: js branch: trunk, size: 3010
19:42
Get rid of OFExceptions.h. file: [ae35beffef] check-in: [cda44767f4] user: js branch: trunk, size: 2850
2011-01-11
19:46
Windows calls it WSAENOTCONN. file: [57b1d6b16e] check-in: [e8c1757fb8] user: js branch: trunk, size: 2769
2011-01-08
16:05
Fix two FIXMEs. file: [62e35b4e2c] check-in: [202daae1d1] user: js branch: trunk, size: 2661
2011-01-01
20:19
Change license. file: [688fd9e6b1] check-in: [da6b3d26cb] user: js branch: trunk, size: 2584
2010-12-11
20:27
Rename a few exception-related methods. file: [66237703fc] check-in: [5e44debc07] user: js branch: trunk, size: 2328
2010-12-09
19:04
Move -[setBlocking] to OFStream. file: [fc3b5a9ea7] check-in: [beb4a0d036] user: js branch: trunk, size: 2314
2010-10-24
13:15
Rename a few methods returning BOOL. file: [a907635fe9] check-in: [b6a39dd3d1] user: js branch: trunk, size: 2596
2010-07-07
21:06
Move most of the code for -[close] to OFStreamSocket. file: [6a144d8c67] check-in: [d81629fead] user: js branch: trunk, size: 2594
20:57
Added: Rename OFSocket to OFStreamSocket.

This is to reflect that it is a connection-based, sequenced, reliable,
two-way byte stream. file: [1c776793df] check-in: [28ea4a8a67] user: js branch: trunk, size: 2343