public unsafe PosixResult TrySend(ArraySegment <byte> buffer) { ValidateSegment(buffer); fixed(byte *buf = buffer.Array) { IOVector ioVector = new IOVector() { Base = buf + buffer.Offset, Count = (void *)buffer.Count }; return(SocketInterop.Send(this, &ioVector, 1)); } }
private static unsafe PosixResult TrySend(int fd, ref ReadableBuffer buffer) { int ioVectorLength = 0; foreach (var memory in buffer) { if (memory.Length == 0) { continue; } ioVectorLength++; if (ioVectorLength == MaxIOVectorSendLength) { // No more room in the IOVector break; } } if (ioVectorLength == 0) { return(new PosixResult(0)); } var ioVectors = stackalloc IOVector[ioVectorLength]; int i = 0; foreach (var memory in buffer) { if (memory.Length == 0) { continue; } void *pointer; memory.TryGetPointer(out pointer); ioVectors[i].Base = pointer; ioVectors[i].Count = (void *)memory.Length; i++; if (i == ioVectorLength) { // No more room in the IOVector break; } } return(SocketInterop.Send(fd, ioVectors, ioVectorLength)); }
public unsafe PosixResult TrySend(IOVector *ioVectors, int ioVectorLen) { return(SocketInterop.Send(this, ioVectors, ioVectorLen)); }