ObjFW  Check-in [1e35805366]

Overview
Comment:Don't set errno in sockets on Win32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1e35805366bc545bc545e0590a9543d6b74bcbce6e7803124388e19c06cdbfe3
User & Date: js on 2010-04-10 21:37:57
Other Links: manifest | tags
Context
2010-04-10
21:43
Minor fix for -[join] in OFThread. check-in: cc17787021 user: js tags: trunk
21:37
Don't set errno in sockets on Win32. check-in: 1e35805366 user: js tags: trunk
21:35
Add a few defines that Win32 needs. check-in: 5dc16f28aa user: js tags: trunk
Changes

Modified src/OFSocket.m from [3aa367c99c] to [eff73867f1].

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
	   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;







>
>


>



















>
>


>







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
94
95
96
97
	   intoBuffer: (char*)buf
{
	ssize_t ret;

	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa];

#ifndef _WIN32
	/* FIXME: We want a sane error message on Win32 as well */
	if (eos)
		errno = ENOTCONN;
#endif

	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];

#ifndef _WIN32
	/* FIXME: We want a sane error message on Win32 as well */
	if (eos)
		errno = ENOTCONN;
#endif

	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;