Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MediaBackupEJB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kai Markus Tegtmeier
MediaBackupEJB
Commits
524b4f8b
Commit
524b4f8b
authored
1 year ago
by
tonschnoer
Browse files
Options
Downloads
Patches
Plain Diff
implemented commands
parent
85ce7d6e
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MediaBackupEJB/src/main/java/de/kmt/ndr/TCPClient.java
+15
-10
15 additions, 10 deletions
MediaBackupEJB/src/main/java/de/kmt/ndr/TCPClient.java
with
15 additions
and
10 deletions
MediaBackupEJB/src/main/java/de/kmt/ndr/TCPClient.java
+
15
−
10
View file @
524b4f8b
...
...
@@ -20,7 +20,8 @@ public class TCPClient {
public
void
run
()
{
byte
[]
buffer
=
new
byte
[
32768
];
byte
[]
buffer
=
new
byte
[
1048576
];
long
bytesread
=
0
;
try
{
...
...
@@ -35,19 +36,22 @@ public class TCPClient {
// request file from server
System
.
out
.
print
(
"Request "
+
Config
.
file
);
out
.
write
(
Config
.
file
);
out
.
write
(
"GET |"
+
Config
.
file
);
out
.
flush
();
while
(
true
)
{
// read up to 32768 bytes from stream
int
readbytes
=
is
.
read
(
buffer
,
0
,
32768
);
System
.
out
.
print
(
"."
);
// read up to 1048576 bytes from stream
int
readbytes
=
is
.
read
(
buffer
,
0
,
1048576
);
bytesread
=
bytesread
+
readbytes
;
System
.
out
.
println
(
"Read "
+
String
.
valueOf
(
bytesread
)
+
" bytes"
);
// check if
32
76
8
bytes where read (i.e. there are some more)
if
(
readbytes
<
32
76
8
)
{
// check if
10485
76 bytes where read (i.e. there are some more)
if
(
readbytes
<
10485
76
)
{
// less than
32
76
8
bytes are read. Check if last 3 bytes are "END". If so: stop receiving data
// less than
10485
76 bytes are read. Check if last 3 bytes are "END". If so: stop receiving data
if
((
buffer
[
readbytes
-
3
]==
0x45
)
&
(
buffer
[
readbytes
-
2
]==
0x4e
)
&
(
buffer
[
readbytes
-
1
]==
0x44
))
{
System
.
out
.
println
(
"Schluss"
);
...
...
@@ -55,13 +59,14 @@ public class TCPClient {
if
(
readbytes
>
3
)
{
dos
.
write
(
buffer
,
0
,
readbytes
-
3
);
}
// leave while(true) loop
break
;
}
else
{
// if bytesread <
32
76
8
, but no ending Tag "END" -> write buffer to file
// if bytesread <
10485
76, but no ending Tag "END" -> write buffer to file
dos
.
write
(
buffer
,
0
,
readbytes
);
}
}
else
{
// if bytesread =
32
76
8
, assume there is more and write buffer to file
// if bytesread =
10485
76, assume there is more and write buffer to file
dos
.
write
(
buffer
,
0
,
readbytes
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment