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
d6ed4cd6
Commit
d6ed4cd6
authored
7 years ago
by
Loeffelman, Garrett (Capt)
Browse files
Options
Downloads
Patches
Plain Diff
Delete LoeffelmanAssignment1.java
parent
24357216
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
deliverables/src/MV3500Cohort2018JulySeptember/homework1/LoeffelmanAssignment1.java
+0
-71
0 additions, 71 deletions
...ort2018JulySeptember/homework1/LoeffelmanAssignment1.java
with
0 additions
and
71 deletions
deliverables/src/MV3500Cohort2018JulySeptember/homework1/LoeffelmanAssignment1.java
deleted
100644 → 0
+
0
−
71
View file @
24357216
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
MV3500Cohort2018JulySeptember.homework1
;
import
java.io.OutputStream
;
import
java.io.PrintStream
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
/**
*
* @author garrettloeffelman
*/
public
class
LoeffelmanAssignment1
{
/**
* @param args the command line arguments
*/
public
static
void
main
(
String
[]
args
)
{
try
{
// The ServerSocket waits for a connection from a client.
// It returns a Socket object when the connection occurs.
ServerSocket
serverSocket
=
new
ServerSocket
(
2317
);
// The Socket object represents the connection between
// the server and client, including a full duplex
// connection
Socket
clientConnection
=
serverSocket
.
accept
();
// Use Java io classes to write text (as opposed to
// unknown bytes of some sort) to the client
OutputStream
os
=
clientConnection
.
getOutputStream
();
PrintStream
ps
=
new
PrintStream
(
os
);
ps
.
println
(
"Nice job! You (the client) connected to port 2317, lets see if anything else is open!"
);
//to remote client
ps
.
println
(
"type 'nc -z -v {host-name-here} 2300-2400'"
);
// to remote client
System
.
out
.
println
(
"This is the server response by LoeffelmanExample1"
);
System
.
out
.
println
(
"A client connected to this server and was instructed to check open ports"
);
// to server console
// "flush()" in important in that it forces a write
// across what is in fact a slow connection
ps
.
flush
();
clientConnection
.
close
();
ServerSocket
serverSocket2
=
new
ServerSocket
(
2350
);
Socket
clientConnection2
=
serverSocket2
.
accept
();
OutputStream
os2
=
clientConnection2
.
getOutputStream
();
PrintStream
ps2
=
new
PrintStream
(
os2
);
ps
.
println
(
"WOW you're good! You found the open port 2350!"
);
//to remote client
ps
.
println
(
"shutting down now, thanks for your help"
);
// to remote client
System
.
out
.
println
(
"Your client found the open port. This is the server response by LoeffelmanExample1"
);
// to server console
ps
.
flush
();
clientConnection
.
close
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"problem with networking: "
+
e
);
}
}
}
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