Ejemplo n.º 1
0
        public int Available_internal(out int error)
        {
            error = 0;
            int r = 0;

            if (jSocket == null || !jSocket.isConnected())
            {
                return(r);
            }

            try
            {
                r = jSocket.getInputStream().available();
            }
            catch (Exception e)
            {
                error = 10054;                 //WSAECONNRESET (Connection reset by peer)
                r     = 0;
#if DEBUG
                Console.WriteLine("Caught exception during Available_internal - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace);
#endif
            }

            return(r);
        }
Ejemplo n.º 2
0
 private Socket(rtl.SOCKET handle)
         #endif
 {
     fHandle = handle;
                 #if cooper
     fSocketInput  = fHandle.getInputStream();
     fSocketOutput = fHandle.getOutputStream();
                 #endif
 }
Ejemplo n.º 3
0
        public void Connect(EndPoint remoteEP)
        {
            var lEndPoint = (IPEndPoint)remoteEP;

                        #if cooper
            var lAddress = java.net.InetAddress.getByAddress(lEndPoint.Address.GetAddressBytes());
            fHandle       = new java.net.Socket(lAddress, lEndPoint.Port);
            fSocketInput  = fHandle.getInputStream();
            fSocketOutput = fHandle.getOutputStream();
                        #else
            void *lPointer;
            int   lSize;
                        #if posix || toffee || darwin || android
            rtl.__struct_sockaddr_in  lIPv4;
            rtl.__struct_sockaddr_in6 lIPv6;
                        #if posix && !darwin && !android
            rtl.__CONST_SOCKADDR_ARG lSockAddr;
                        #else
            rtl.__struct_sockaddr lSockAddr;
                        #endif
                        #else
            rtl.SOCKADDR_IN lIPv4;
            sockaddr_in6    lIPv6;
                        #endif


            IPEndPointToNative(lEndPoint, out lIPv4, out lIPv6, out lPointer, out lSize);
            var lRes = 0;
                        #if posix && !darwin && !android
            lSockAddr.__sockaddr__ = (rtl.__struct_sockaddr *)lPointer;
            lRes = rtl.connect(fHandle, lSockAddr, lSize);
                        #elif toffee || darwin || android
            lRes = rtl.connect(fHandle, (rtl.__struct_sockaddr *)lPointer, lSize);
                        #else
            lRes = rtl.connect(fHandle, lPointer, lSize);
                        #endif
            if (lRes != 0)
            {
                throw new Exception("Error connecting socket");
            }
                        #endif

            Connected = true;
        }
Ejemplo n.º 4
0
 private Socket(java.net.Socket handle)
 {
     fHandle       = handle;
     fSocketInput  = fHandle.getInputStream();
     fSocketOutput = fHandle.getOutputStream();
 }