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
74
75
76
77
78
79
80
81
82
83
|
saddr = NULL;
return self;
}
- (BOOL)atEndOfStream
{
/* FIXME: Implement this! */
return NO;
}
- (size_t)readNBytes: (size_t)size
intoBuffer: (char*)buf
{
ssize_t ret;
if (sock == INVALID_SOCKET)
@throw [OFNotConnectedException newWithClass: isa];
switch ((ret = recv(sock, buf, size, 0))) {
case 0:
@throw [OFNotConnectedException newWithClass: isa];
case -1:
@throw [OFReadFailedException newWithClass: isa
andSize: size];
}
/* This is safe, as we already checked < 1 */
return ret;
}
- (size_t)writeNBytes: (size_t)size
fromBuffer: (const char*)buf
{
ssize_t ret;
|
<
<
|
|
|
<
<
<
|
<
|
>
>
<
|
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
74
75
76
77
78
|
saddr = NULL;
return self;
}
- (BOOL)atEndOfStream
{
return eos;
}
- (size_t)readNBytes: (size_t)size
intoBuffer: (char*)buf
{
ssize_t ret;
if (sock == INVALID_SOCKET || eos)
@throw [OFNotConnectedException newWithClass: isa];
if ((ret = recv(sock, buf, size, 0)) < 0)
@throw [OFReadFailedException newWithClass: isa];
if (ret == 0)
eos = YES;
return ret;
}
- (size_t)writeNBytes: (size_t)size
fromBuffer: (const char*)buf
{
ssize_t ret;
|