1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
package my.testsms.essaie;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
//import java.net.SocketAddress;
import java.net.UnknownHostException;
public class Essaie {
private InetAddress remoteaddr;
private boolean status;
private Socket client;
private BindTransceiver bindtrans;
private OutputStream sout;
private InputStream sin;
private Connection conn;
String ipaddress = "10.75.0.100";
int port = 5016;
int localPort = 2500;
String sysId = "admin";
String pwd = "good";
String systemType = "0";
int sourceTON = 0;
int sourceNPI = 0;
String addrRange = " ";
boolean retry = false;
BindResp bindResponse;
public void connect() throws UnknownHostException, IOException {
// Create the TCP link...
InetAddress localAddress = InetAddress.getByName("ptb_harold");
System.out.println(localAddress);
client = new Socket(ipaddress, port, localAddress, localPort);
System.out.println(client.getRemoteSocketAddress());
remoteaddr = client.getInetAddress();
System.out.println(remoteaddr);
TcpLink link = new TcpLink(remoteaddr, port);
link.open();
status = link.isConnected();
System.out.println(status);
}
public static void main(String[] args) throws UnknownHostException, IOException {
Essaie test = new Essaie();
test.connect();
}
} |
Partager