Java Reference
In-Depth Information
/** Debugging flag */
protected
protected static
static
boolean
boolean
debug
=
false
false
;
/** TFTP op-code for a read request */
public
public final
int
OP_RRQ
=
1
;
/** TFTP op-code for a read request */
public
final
int
public final
int
OP_WRQ
=
2
;
/** TFTP op-code for a read request */
public
final
int
public final
int
OP_DATA
=
3
;
/** TFTP op-code for a read request */
public
final
int
public final
int
OP_ACK
=
4
;
/** TFTP op-code for a read request */
public
final
int
public final
final
int
int
OP_ERROR
=
5
;
protected
protected final
final static
static
int
int
PACKET_SIZE
=
516
;
// == 2 + 2 + 512
protected
protected
String host
;
protected
protected
InetAddress servAddr
;
protected
protected
DatagramSocket sock
;
protected
protected
byte
byte
buffer
[];
protected
protected
DatagramPacket inp
,
outp
;
/** The main program that drives this network client.
* @param argv[0] hostname, running TFTP server
* @param argv[1..n] filename(s), must be at least one
*/
public
public static
static
void
void
main
(
String
[]
argv
)
throws
throws
IOException
{
iif
(
argv
.
length
<
2
) {
System
.
err
.
println
(
"usage: rcat host filename[...]"
);
System
.
exit
(
1
);
}
iif
(
debug
)
System
.
err
.
println
(
"Java RemCat starting"
);
RemCat rc
=
new
new
RemCat
(
argv
[
0
]);
for
for
(
int
int
i
=
1
;
i
<
argv
.
length
;
i
++) {
iif
(
debug
)
System
.
err
.
println
(
"-- Starting file "
+
argv
[
0
] +
":"
+
argv
[
i
] +
"---"
);
rc
.
readFile
(
argv
[
i
]);
}
}
RemCat
(
String host
)
throws
throws
IOException
{
super
super
();
this
this
.
host
=
host
;
servAddr
=
InetAddress
.
getByName
(
host
);
sock
=
new
new
DatagramSocket
();