Ejemplo n.º 1
0
 private int checkConnect(FileDescriptor fd, boolean block, boolean ready) throws IOException {
   try {
     if (false) throw new cli.System.Net.Sockets.SocketException();
     if (false) throw new cli.System.ObjectDisposedException("");
     if (block || ready || asyncConnect.get_IsCompleted()) {
       cli.System.IAsyncResult res = asyncConnect;
       asyncConnect = null;
       fd.getSocket().EndConnect(res);
       // work around for blocking issue
       fd.getSocket().set_Blocking(isBlocking());
       return 1;
     } else {
       return IOStatus.UNAVAILABLE;
     }
   } catch (cli.System.Net.Sockets.SocketException x) {
     throw new ConnectException(x.getMessage());
   } catch (cli.System.ObjectDisposedException x1) {
     throw new SocketException("Socket is closed");
   }
 }
Ejemplo n.º 2
0
 private int connectImpl(InetAddress remote, int remotePort, int trafficClass) throws IOException {
   try {
     if (false) throw new cli.System.Net.Sockets.SocketException();
     if (false) throw new cli.System.ObjectDisposedException("");
     cli.System.Net.IPEndPoint ep =
         new cli.System.Net.IPEndPoint(
             PlainSocketImpl.getAddressFromInetAddress(remote), remotePort);
     if (isBlocking()) {
       fd.getSocket().Connect(ep);
       return 1;
     } else {
       asyncConnect = fd.getSocket().BeginConnect(ep, null, null);
       return IOStatus.UNAVAILABLE;
     }
   } catch (cli.System.Net.Sockets.SocketException x) {
     throw new ConnectException(x.getMessage());
   } catch (cli.System.ObjectDisposedException x1) {
     throw new SocketException("Socket is closed");
   }
 }