ObjFW  Diff

Differences From Artifact [5b827e504d]:

  • File src/OFStreamSocket.m — part of check-in [8d2a5052fd] at 2014-01-25 17:39:13 on branch trunk — 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). (user: js, size: 3523) [annotate] [blame] [check-ins using]

To Artifact [c2425f91c0]:

  • File src/OFStreamSocket.m — part of check-in [81d47f4398] at 2014-01-25 19:33:57 on branch trunk — 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. (user: js, size: 3129) [annotate] [blame] [check-ins using]


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

#include <string.h>

#include <unistd.h>

#include <errno.h>

#include <sys/types.h>
#ifdef OF_HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif

#import "OFStreamSocket.h"

#import "OFInitializationFailedException.h"
#import "OFNotConnectedException.h"
#import "OFReadFailedException.h"
#import "OFSetOptionFailedException.h"
#import "OFWriteFailedException.h"

#ifdef __wii__
# define BOOL OGC_BOOL
# include <network.h>
# undef BOOL
# define recv(sock, buf, len, flags) net_recv(sock, buf, len, flags)
# define send(sock, buf, len, flags) net_send(sock, buf, len, flags)
#endif

#ifndef INVALID_SOCKET
# define INVALID_SOCKET -1
#endif

#ifdef _WIN32
# define close(sock) closesocket(sock)
#endif

@implementation OFStreamSocket
+ (void)initialize
{
#ifdef _WIN32
	WSADATA wsa;
#endif







<
<
<
<
<








<
<
<
<
<
<
<
|
<
<
<
<
<
<
<







20
21
22
23
24
25
26





27
28
29
30
31
32
33
34







35







36
37
38
39
40
41
42

#include <string.h>

#include <unistd.h>

#include <errno.h>






#import "OFStreamSocket.h"

#import "OFInitializationFailedException.h"
#import "OFNotConnectedException.h"
#import "OFReadFailedException.h"
#import "OFSetOptionFailedException.h"
#import "OFWriteFailedException.h"








#import "socket_helpers.h"








@implementation OFStreamSocket
+ (void)initialize
{
#ifdef _WIN32
	WSADATA wsa;
#endif