public static RubyArray Accept(RubyContext/*!*/ context, RubySocket/*!*/ self) { RubyArray result = new RubyArray(2); RubySocket s = new RubySocket(context, self.Socket.Accept()); result.Add(s); SocketAddress addr = s.Socket.RemoteEndPoint.Serialize(); result.Add(MutableString.CreateAscii(addr.ToString())); return result; }
public static RubyArray AcceptNonBlocking(RubyContext/*!*/ context, RubySocket/*!*/ self) { bool blocking = self.Socket.Blocking; try { self.Socket.Blocking = false; return Accept(context, self); } finally { // Reset the blocking self.Socket.Blocking = blocking; } }
public static RubyArray/*!*/ SysAccept(RubyContext/*!*/ context, RubySocket/*!*/ self) { RubyArray result = new RubyArray(2); // TODO: Do we need some kind of strong reference to the socket // here to stop the RubySocket from being garbage collected? RubySocket s = new RubySocket(context, self.Socket.Accept()); result.Add(s.FileDescriptor); SocketAddress addr = s.Socket.RemoteEndPoint.Serialize(); result.Add(MutableString.Create(addr.ToString())); return result; }
public static RubyArray/*!*/ ReceiveFrom(RubyContext/*!*/ context, RubySocket/*!*/ self, int length, object/*Numeric*/ flags) { SocketFlags sFlags = ConvertToSocketFlag(context, flags); byte[] buffer = new byte[length]; EndPoint fromEP = new IPEndPoint(IPAddress.Any, 0); int received = self.Socket.ReceiveFrom(buffer, sFlags, ref fromEP); MutableString str = MutableString.CreateBinary(); str.Append(buffer, 0, received); str.IsTainted = true; return RubyOps.MakeArray2(str, GetAddressArray(context, fromEP)); }
public static RubyArray/*!*/ ReceiveFrom(RubyContext/*!*/ context, RubySocket/*!*/ self, int length) { return ReceiveFrom(context, self, length, null); }
public static int Listen(RubyContext/*!*/ context, RubySocket/*!*/ self, int backlog) { self.Socket.Listen(backlog); return 0; }
public static int ConnectNonBlocking(RubyContext/*!*/ context, RubySocket/*!*/ self, MutableString sockaddr) { bool blocking = self.Socket.Blocking; try { self.Socket.Blocking = false; return Connect(context, self, sockaddr); } finally { // Reset the blocking self.Socket.Blocking = blocking; } }
public static int Connect(RubyContext/*!*/ context, RubySocket/*!*/ self, MutableString sockaddr) { IPEndPoint ep = UnpackSockAddr(sockaddr); self.Socket.Connect(ep); return 0; }
public static RubyArray/*!*/ ReceiveFrom(ConversionStorage<int>/*!*/ fixnumCast, RubySocket/*!*/ self, int length) { return ReceiveFrom(fixnumCast, self, length, null); }
public static RubyArray /*!*/ ReceiveFrom(ConversionStorage <int> /*!*/ fixnumCast, RubySocket /*!*/ self, int length) { return(ReceiveFrom(fixnumCast, self, length, null)); }
public static int Listen(RubyContext /*!*/ context, RubySocket /*!*/ self, int backlog) { self.Socket.Listen(backlog); return(0); }