Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LiFiBenchMarkingNetwork
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
Container Registry
Model registry
Operate
Environments
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
Savage
LiFiGroup
LiFiBenchMarkingNetwork
Commits
c3d1fbcc
Commit
c3d1fbcc
authored
6 years ago
by
Terry D. Norbraten
Browse files
Options
Downloads
Patches
Plain Diff
attempt to close Sever by normal thread death
parent
8594ef31
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/edu/nps/moves/lifi/LiFiBenchmark.java
+37
-14
37 additions, 14 deletions
src/edu/nps/moves/lifi/LiFiBenchmark.java
with
37 additions
and
14 deletions
src/edu/nps/moves/lifi/LiFiBenchmark.java
+
37
−
14
View file @
c3d1fbcc
...
...
@@ -61,8 +61,7 @@ public class LiFiBenchmark
public
static
void
main
(
String
[]
args
)
{
LiFiBenchmark
bm
=
new
LiFiBenchmark
(
args
);
bm
.
start
();
new
LiFiBenchmark
(
args
).
start
();
}
public
LiFiBenchmark
(
String
[]
args
)
...
...
@@ -110,16 +109,19 @@ public class LiFiBenchmark
}
int
repsCount
=
reps
;
int
discardsCount
=
discards
;
long
readAcc
;
long
startms
;
int
read
;
byte
[]
buff
;
while
(
repsCount
--
>
0
)
{
long
readAcc
;
long
startms
=
System
.
currentTimeMillis
();
startms
=
System
.
currentTimeMillis
();
try
(
Socket
sock
=
new
Socket
(
targetIp
,
targetPort
))
{
readAcc
=
0
l
;
byte
[]
buff
=
new
byte
[
READ_BUFFER_SIZE
];
buff
=
new
byte
[
READ_BUFFER_SIZE
];
while
(
true
)
{
int
read
=
sock
.
getInputStream
().
read
(
buff
);
read
=
sock
.
getInputStream
().
read
(
buff
);
if
(
read
==
-
1
)
break
;
readAcc
+=
read
;
...
...
@@ -140,8 +142,10 @@ public class LiFiBenchmark
private
void
doServer
()
{
ServerSocket
ssock
=
null
;
try
{
ServerSocket
ssock
=
new
ServerSocket
(
targetPort
);
ssock
=
new
ServerSocket
(
targetPort
);
System
.
out
.
println
(
"Serving from "
+
Inet4Address
.
getLocalHost
().
getHostAddress
());
System
.
out
.
println
(
"Waiting on port "
+
targetPort
);
...
...
@@ -155,27 +159,46 @@ public class LiFiBenchmark
catch
(
IOException
ex
)
{
System
.
err
.
println
(
"Exception waiting for connections: "
+
ex
.
getMessage
());
System
.
exit
(-
1
);
}
}
}
finally
{
try
{
if
(
ssock
!=
null
)
ssock
.
close
();
}
catch
(
IOException
ex
)
{}
}
}
private
void
handleConnection
(
Socket
sock
)
{
new
Thread
(()
->
{
Thread
thread
=
new
Thread
(()
->
{
byte
[]
ba
=
new
byte
[
WRITE_BUFFER_SIZE
];
int
wrote
=
0
;
byte
fill
=
0
;
try
{
while
(
true
)
{
Arrays
.
fill
(
ba
,
fill
++);
// The pipe will be broken by the networkRead method due to read limit
// imposed
sock
.
getOutputStream
().
write
(
ba
);
wrote
+=
ba
.
length
;
}
}
catch
(
IOException
ex
)
{
System
.
err
.
println
(
"Shutting down: "
+
ex
.
getClass
().
getSimpleName
()
+
": "
+
ex
.
getLocalizedMessage
());
System
.
err
.
println
(
"Wrote "
+
wrote
);
String
pre
=
"Shutting down"
;
String
msg
=
ex
.
getClass
().
getSimpleName
()
+
": "
+
ex
.
getLocalizedMessage
();
if
(
msg
.
contains
(
"Broken pipe"
))
System
.
out
.
print
(
pre
);
else
System
.
err
.
println
(
pre
+
": "
+
msg
);
}
finally
{
try
{
sock
.
close
();
}
catch
(
IOException
ex
)
{}
System
.
out
.
println
(
"\nWrote "
+
wrote
+
" bytes"
);
}
}).
start
();
});
thread
.
setDaemon
(
true
);
thread
.
start
();
}
private
long
handleSize
(
String
s
)
...
...
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