Skip to content

Commit 1046a03

Browse files
committed
Use NET_Status in public API (#137)
1 parent 15cc556 commit 1046a03

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/SDL_net.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ static int SDLCALL ResolverThread(void *data)
284284
SDL_Delay(RandomNumberBetween(250, 2000 + (50 * simulated_loss)));
285285
}
286286

287-
int outcome;
287+
NET_Status outcome;
288288
if (!simulated_loss || (RandomNumberBetween(0, 100) > simulated_loss)) {
289289
outcome = ResolveAddress(addr);
290290
} else {
291-
outcome = -1;
291+
outcome = NET_FAILURE;
292292
addr->errstr = SDL_strdup("simulated failure");
293293
}
294294

@@ -1371,10 +1371,10 @@ static bool PumpDatagramSocket(NET_DatagramSocket *sock)
13711371
while (sock->pending_output_len > 0) {
13721372
SDL_assert(sock->pending_output != NULL);
13731373
NET_Datagram *dgram = sock->pending_output[0];
1374-
const int rc = SendOneDatagram(sock, dgram->addr, dgram->port, dgram->buf, dgram->buflen);
1375-
if (rc < 0) { // failure!
1374+
const NET_Status rc = SendOneDatagram(sock, dgram->addr, dgram->port, dgram->buf, dgram->buflen);
1375+
if (rc == NET_FAILURE) { // failure!
13761376
return false;
1377-
} else if (rc == 0) { // wouldblock
1377+
} else if (rc == NET_WOULDBLOCK) {
13781378
break; // stop trying to send packets for now.
13791379
}
13801380

@@ -1408,13 +1408,13 @@ bool NET_SendDatagram(NET_DatagramSocket *sock, NET_Address *addr, Uint16 port,
14081408
}
14091409

14101410
if (sock->pending_output_len == 0) { // nothing queued? See if we can just send this without queueing.
1411-
const int rc = SendOneDatagram(sock, addr, port, buf, buflen);
1412-
if (rc < 0) {
1411+
const NET_Status rc = SendOneDatagram(sock, addr, port, buf, buflen);
1412+
if (rc == NET_FAILURE) {
14131413
return false; // error string was already set in SendOneDatagram.
1414-
} else if (rc == 1) {
1414+
} else if (rc == NET_SUCCESS) {
14151415
return true; // successfully sent.
14161416
}
1417-
// if rc==0, it wasn't sent, because we would have blocked. Queue it for later, below.
1417+
// if rc == NET_WOULDBLOCK, it wasn't sent. Queue it for later, below.
14181418
}
14191419

14201420
// queue this up for sending later.

0 commit comments

Comments
 (0)