Fix bug 1491

Add std.socket to the base unittest suite.
This commit is contained in:
Brad Roberts 2007-10-14 05:06:15 +00:00
parent f3e1773c81
commit ad29e17ff3
4 changed files with 11 additions and 4 deletions

View file

@ -236,6 +236,7 @@ enum: int
MSG_OOB = 0x1,
MSG_PEEK = 0x2,
MSG_DONTROUTE = 0x4,
MSG_NOSIGNAL = 0x4000,
}

View file

@ -381,6 +381,7 @@ enum: int
MSG_OOB = 0x1,
MSG_PEEK = 0x2,
MSG_DONTROUTE = 0x4,
MSG_NOSIGNAL = 0x0, /// not supported on win32, would be 0x4000 if it was
}

View file

@ -729,11 +729,12 @@ enum SocketShutdown: int
/// Flags may be OR'ed together:
enum SocketFlags: int
{
NONE = 0, /// no flags specified
NONE = 0, /// no flags specified
OOB = MSG_OOB, /// out-of-band stream data
PEEK = MSG_PEEK, /// peek at incoming data without removing it from the queue, only for receiving
OOB = MSG_OOB, /// out-of-band stream data
PEEK = MSG_PEEK, /// peek at incoming data without removing it from the queue, only for receiving
DONTROUTE = MSG_DONTROUTE, /// data should not be subject to routing; this flag may be ignored. Only for sending
NOSIGNAL = MSG_NOSIGNAL, /// don't send SIGPIPE signal on socket write error and instead return EPIPE
}
@ -1270,6 +1271,7 @@ class Socket
//returns number of bytes actually sent, or -1 on error
int send(void[] buf, SocketFlags flags)
{
flags |= SocketFlags.NOSIGNAL;
int sent = .send(sock, buf.ptr, buf.length, cast(int)flags);
return sent;
}
@ -1277,7 +1279,7 @@ class Socket
/// ditto
int send(void[] buf)
{
return send(buf, SocketFlags.NONE);
return send(buf, SocketFlags.NOSIGNAL);
}
/**
@ -1285,6 +1287,7 @@ class Socket
*/
int sendTo(void[] buf, SocketFlags flags, Address to)
{
flags |= SocketFlags.NOSIGNAL;
int sent = .sendto(sock, buf.ptr, buf.length, cast(int)flags, to.name(), to.nameLen());
return sent;
}
@ -1300,6 +1303,7 @@ class Socket
/// ditto
int sendTo(void[] buf, SocketFlags flags)
{
flags |= SocketFlags.NOSIGNAL;
int sent = .sendto(sock, buf.ptr, buf.length, cast(int)flags, null, 0);
return sent;
}

View file

@ -52,6 +52,7 @@ import std.uni;
import std.file;
import std.signals;
import std.cpuid;
import std.socket;
int main(char[][] args)
{