Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
Session10_NargesSalehi_9628055_Part1
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
9628055
Session10_NargesSalehi_9628055_Part1
Commits
f0781a31
Commit
f0781a31
authored
Jun 10, 2020
by
nargessalehi98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add client
parents
Pipeline
#5121
canceled with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
0 deletions
+66
-0
client1.iml
client1.iml
+12
-0
Client1.class
out/production/client1/Client1.class
+0
-0
Main.class
out/production/client1/Main.class
+0
-0
Client1.java
src/Client1.java
+45
-0
Main.java
src/Main.java
+9
-0
No files found.
client1.iml
0 → 100644
View file @
f0781a31
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src"
isTestSource=
"false"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
out/production/client1/Client1.class
0 → 100644
View file @
f0781a31
File added
out/production/client1/Main.class
0 → 100644
View file @
f0781a31
File added
src/Client1.java
0 → 100644
View file @
f0781a31
import
java.net.*
;
import
java.io.*
;
public
class
Client1
{
private
Socket
socket
=
null
;
private
DataInputStream
console
=
null
;
private
DataOutputStream
streamOut
=
null
;
public
Client1
(
String
serverName
,
int
serverPort
)
{
System
.
out
.
println
(
"Establishing connection. Please wait ..."
);
try
{
socket
=
new
Socket
(
serverName
,
serverPort
);
System
.
out
.
println
(
"Connected: "
+
socket
);
start
();
}
catch
(
UnknownHostException
uhe
)
{
System
.
out
.
println
(
"Host unknown: "
+
uhe
.
getMessage
());
}
catch
(
IOException
ioe
)
{
System
.
out
.
println
(
"Unexpected exception: "
+
ioe
.
getMessage
());
}
String
line
=
""
;
while
(!
line
.
equals
(
"over"
))
{
try
{
assert
console
!=
null
;
line
=
console
.
readLine
();
streamOut
.
writeUTF
(
line
);
streamOut
.
flush
();
}
catch
(
IOException
ioe
)
{
System
.
out
.
println
(
"Sending error: "
+
ioe
.
getMessage
());
}
try
{
DataInputStream
streamIn
=
new
DataInputStream
(
new
BufferedInputStream
(
socket
.
getInputStream
()));
String
line2
=
streamIn
.
readUTF
();
System
.
out
.
println
(
line2
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
public
void
start
()
throws
IOException
{
console
=
new
DataInputStream
(
System
.
in
);
streamOut
=
new
DataOutputStream
(
socket
.
getOutputStream
());
}
}
\ No newline at end of file
src/Main.java
0 → 100644
View file @
f0781a31
import
java.io.IOException
;
public
class
Main
{
public
static
void
main
(
String
args
[]){
Client1
client1
=
new
Client1
(
"Localhost"
,
5001
);
}
}
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