Example usage for org.apache.commons.net.tftp TFTPClient setDatagramSocketFactory

List of usage examples for org.apache.commons.net.tftp TFTPClient setDatagramSocketFactory

Introduction

In this page you can find the example usage for org.apache.commons.net.tftp TFTPClient setDatagramSocketFactory.

Prototype

public void setDatagramSocketFactory(DatagramSocketFactory factory) 

Source Link

Document

Sets the DatagramSocketFactory used by the DatagramSocketClient to open DatagramSockets.

Usage

From source file:org.xerela.net.sim.tftp.TftpInterface.java

public void sendFile(IpAddress localIp, IpAddress remoteIp, String filename, InputStream file)
        throws UnknownHostException, IOException {
    TFTPClient client = null;
    try {/*from w w w  .  j  a v a  2 s.  c o  m*/
        client = new TFTPClient();
        client.setDatagramSocketFactory(new SocketFactory(localIp.getRealAddress()));
        client.open();
        client.sendFile(filename, TFTPClient.BINARY_MODE, file, remoteIp.getIp());
    } finally {
        try {
            client.close();
        } catch (NullPointerException e) {
        }
    }
}