Inheritance: RubyBasicSocket
Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 public static RubyArray/*!*/ ReceiveFrom(RubyContext/*!*/ context, RubySocket/*!*/ self, int length) {
     return ReceiveFrom(context, self, length, null);
 }
Ejemplo n.º 6
0
 public static int Listen(RubyContext/*!*/ context, RubySocket/*!*/ self, int backlog) {
     self.Socket.Listen(backlog);
     return 0;
 }
Ejemplo n.º 7
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;
     }
 }
Ejemplo n.º 8
0
 public static int Connect(RubyContext/*!*/ context, RubySocket/*!*/ self, MutableString sockaddr) {
     IPEndPoint ep = UnpackSockAddr(sockaddr);
     self.Socket.Connect(ep);
     return 0;
 }
Ejemplo n.º 9
0
 public static RubyArray/*!*/ ReceiveFrom(ConversionStorage<int>/*!*/ fixnumCast, RubySocket/*!*/ self, int length) {
     return ReceiveFrom(fixnumCast, self, length, null);
 }
Ejemplo n.º 10
0
 public static RubyArray /*!*/ ReceiveFrom(ConversionStorage <int> /*!*/ fixnumCast, RubySocket /*!*/ self, int length)
 {
     return(ReceiveFrom(fixnumCast, self, length, null));
 }
Ejemplo n.º 11
0
 public static int Listen(RubyContext /*!*/ context, RubySocket /*!*/ self, int backlog)
 {
     self.Socket.Listen(backlog);
     return(0);
 }