Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
firstProject
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9531702
firstProject
Commits
cb40a021
Commit
cb40a021
authored
Dec 17, 2018
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cs
parent
7a8c0ad3
Pipeline
#66
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
Main.java
Main.java
+30
-0
No files found.
Main.java
0 → 100644
View file @
cb40a021
package
ir
.
ac
.
aut
.
ceit
.
udpproxy
;
import
ir.ac.aut.ceit.udpproxy.proxy.Server
;
import
java.io.IOException
;
import
java.net.DatagramPacket
;
import
java.net.DatagramSocket
;
import
java.net.InetAddress
;
import
java.util.Scanner
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
new
Server
().
start
();
// start the server thread
// read user input and sent it to proxy server with udp packets
System
.
out
.
println
(
"Please enter a valid url (http://aut.ac.ir/) that ends with slash:"
);
Scanner
stdin
=
new
Scanner
(
System
.
in
);
String
url
=
stdin
.
next
();
// read a line from stdin
// separate host and path from the given url
String
request
=
"GET / HTTP/1.1\n"
+
"Host: "
+
url
;
// build a http request
try
{
DatagramSocket
client
=
new
DatagramSocket
();
client
.
send
(
new
DatagramPacket
(
request
.
getBytes
(),
request
.
length
(),
InetAddress
.
getLoopbackAddress
(),
1373
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment