1 17 18 package org.apache.james.transport.mailets; 19 20 import java.net.InetAddress ; 21 import java.net.Socket ; 22 import java.net.UnknownHostException ; 23 import java.io.IOException ; 24 25 39 public class RemoteDeliverySocketFactory { 40 41 44 static void setBindAdress(String addr) throws UnknownHostException { 45 if (addr == null) bindAddress = null; 46 else bindAddress = InetAddress.getByName(addr); 47 } 48 49 52 public static RemoteDeliverySocketFactory getDefault() { 53 return new RemoteDeliverySocketFactory(); 54 } 55 56 60 public Socket createSocket() throws IOException { 61 throw new IOException ("Incompatible JavaMail version, " + 62 "cannot bound socket"); 63 } 64 65 69 public Socket createSocket(String host, int port) 70 throws IOException , UnknownHostException { 71 return new Socket (host, port, bindAddress, 0); 72 } 73 74 78 public Socket createSocket(String host, 79 int port, 80 InetAddress clientHost, 81 int clientPort) 82 throws IOException , 83 UnknownHostException { 84 return new Socket (host, port, 85 clientHost == null ? bindAddress : clientHost, clientPort); 86 } 87 88 92 public Socket createSocket(InetAddress host, int port) throws IOException { 93 return new Socket (host, port, bindAddress, 0); 94 } 95 96 100 public Socket createSocket(InetAddress address, 101 int port, 102 InetAddress clientAddress, 103 int clientPort) 104 throws IOException { 105 return new Socket (address, port, 106 clientAddress == null ? bindAddress : clientAddress, 107 clientPort); 108 } 109 110 114 private static InetAddress bindAddress; 115 } 116 | Popular Tags |