Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
NetworkedGraphicsMV3500
Commits
15045456
Commit
15045456
authored
4 years ago
by
brutzman
Browse files
Options
Downloads
Patches
Plain Diff
documentation improvements
parent
b492714e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/src/UdpMulticastExamples/UdpSender.java
+7
-4
7 additions, 4 deletions
examples/src/UdpMulticastExamples/UdpSender.java
with
7 additions
and
4 deletions
examples/src/UdpMulticastExamples/UdpSender.java
+
7
−
4
View file @
15045456
...
...
@@ -20,10 +20,12 @@ public class UdpSender
{
// System properties: https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
public
static
final
String
MY_NAME
=
System
.
getProperty
(
"user.name"
);
// guru incantation 8)
public
static
final
int
SENDING_PORT
=
1414
;
//
public static final int SENDING_PORT = 1414;
// not needed, can let system choose an open local port
public
static
final
int
RECEIVING_PORT
=
1415
;
public
static
final
int
TOTAL_PACKETS_TO_SEND
=
100
;
public
static
final
String
DESTINATION_HOST
=
"localhost"
;
// localhost 127.0.0.1 or argon 10.1.105.1
// here is what we need for lab comms
public
static
final
String
DESTINATION_HOST
=
"10.1.105.16"
;
// localhost 127.0.0.1 or argon 10.1.105.1 or 10.1.105.1 or whatever
@SuppressWarnings
(
"SleepWhileInLoop"
)
public
static
void
main
(
String
[]
args
)
throws
IOException
...
...
@@ -32,7 +34,7 @@ public class UdpSender
DataOutputStream
dos
=
null
;
int
packetID
=
0
;
// counter variable to send in packet
float
value
=
-
1.0f
;
// unreachable value is good sentinel to ensure expected changes occur
String
message
=
"
Hello MV3500"
;
// no really
String
message
=
MY_NAME
+
" says
Hello MV3500"
;
// no really
String
padding
=
new
String
();
try
...
...
@@ -41,7 +43,7 @@ public class UdpSender
System
.
out
.
println
(
UdpSender
.
class
.
getName
()
+
" started..."
);
// Create a UDP socket
udpSocket
=
new
DatagramSocket
(
SENDING_PORT
);
udpSocket
=
new
DatagramSocket
(
);
// let system assign output port, then
SENDING_PORT
not needed
// Put together a message with binary content. "ByteArrayOutputStream"
// is a java.io utility that lets us put together an array of binary
...
...
@@ -82,6 +84,7 @@ public class UdpSender
byteArray
=
baos
.
toByteArray
();
// OK so go get the flushed result...
datagramPacket
.
setData
(
byteArray
);
// and put it in the packet...
udpSocket
.
send
(
datagramPacket
);
// and send it away. boom gone, nonblocking.
// System.out.println("udpSocket output port=" + udpSocket.getLocalPort()); // diagnostic tells what port was chosen by system
if
(
isPacketIdEvenParity
)
padding
=
" "
;
...
...
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