Access Millions of academic & study documents

A TFTP cliente process in c or c++ that can solve the problem of m

Content type
User Generated
Showing Page:
1/5
A TFTP cliente process in c or c++ that can solve the
problem of message formatting and flux control of the
protocol
A TFTP cliente process in c or c++ that can solve the
problem of message formatting and flux control of the
protocol
Solution
package tftpclient; import java.net.*; import
java.io.*; import tftp.*; import
tftpserver.TFTPServerClient; import
tftpserver.TFTPServerClient.TClientRequest;
public class TFTPClient extends Thread { public int
server_port; public String server_ip; public Socket
server_socket; public BufferedOutputStream out;
public BufferedInputStream in; public DataInputStream
fin; public DataOutputStream fout; public
TFTPServerClient.TClientRequest request; public
TFTPClient(int port, String ip) { server_port = port;
server_ip = ip; try { server_socket = new
Socket(server_ip, server_port); } catch
(UnknownHostException unknownHost) {
TFTPUtils.fatalError(\"Unknown host \" + server_ip);

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/5
} catch (IOException ioException) {
TFTPUtils.fatalError(\"Unable to create a socket\"); }
} public boolean sendFile(String filename, String
dest) { TFTPPacket packet_wrq, packet_ack,
packet_data; int bytes_read; int packet_no; byte[]
data = new
byte[TFTPPacket.TFTP_PACKET_DATA_SIZE]; try {
fin = new DataInputStream(new
FileInputStream(\"D:\\\\Users\\\\Vilius\\\\Desktop\\\\tftp\\\\ja
va\\\\src\\\\tftpclient\\\\\" + filename)); } catch
(Exception e) { TFTPUtils.fatalError(\"Unable to open
source file: \" + filename); return false; }
request = TClientRequest.WRQ; if
(server_socket.isConnected()) {
TFTPUtils.puts(\"Connected to \" + server_ip + \" on port \"
+ server_port); } else {
TFTPUtils.fatalError(\"Disconnected unexpectedly\"); }
try { out = new
BufferedOutputStream(server_socket.getOutputStream());
in = new
BufferedInputStream(server_socket.getInputStream());
packet_wrq = new TFTPPacket();
packet_wrq.createWRQ(dest); packet_wrq.dumpData();
TFTPUtils.puts(\"Sending write request to server\");
packet_wrq.sendPacket(out); // wait for ack

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/5

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 5 pages?
Access Now
Unformatted Attachment Preview
A TFTP cliente process in c or c++ that can solve the problem of message formatting and flux control of the protocol A TFTP cliente process in c or c++ that can solve the problem of message formatting and flux control of the protocol Solution package tftpclient; java.io.*; import java.net.*; import tftp.*; tftpserver.TFTPServerClient; import import import tftpserver.TFTPServerClient.TClientRequest; public class TFTPClient extends Thread { server_port; server_socket; public String server_ip; public Socket public BufferedOutputStream out; public BufferedInputStream in; fin; public int public DataInputStream public DataOutputStream fout; public TFTPServerClient.TClientRequest request; TFTPClient(int port, String ip) { server_ip = ip; try { Socket(server_ip, server_port); public server_port = port; server_socket = new } catch (UnknownHostException unknownHost ) { TFTPUtils.fatalError(\"Unknown host \" + server_ip); } catch (IOException ioException) { TFTPUtils.fatalError(\"Unable to create a socket\"); } } public boolean sendFile(String filename, String dest) { TFTPPacket packet_wrq, packet_ack, packet_data; int bytes_read; int packet_no; byte[] data = new byte[TFTPPacket.TFTP_PACKET_DATA_SIZE]; try { fin = new DataInputStream(new FileInputStream(\"D:\\\\Users\\\\Vilius\\\\Desktop\\\\tftp\\\\ja va\\\\src\\\\tftpclient\\\\\" + filename)); (Exception e) { } catch TFTPUtils.fatalError( \"Unable to open source file: \" + filename); return false; ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents