Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoT Server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
jonathan.poalses
IoT Server
Commits
bb55e9d7
Commit
bb55e9d7
authored
Jan 12, 2023
by
Jonathan Poalses
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated gradle and java version, changed to using executor service, added git ignore
parent
bdc81554
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
21 deletions
+85
-21
.gitignore
.gitignore
+64
-0
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+1
-1
Server.java
src/main/java/jonathan/poalses/Server.java
+20
-20
No files found.
.gitignore
0 → 100644
View file @
bb55e9d7
### Leiningen ###
/.lein-*
/.nrepl-port
/.prepl-port
### IntelliJ IDEA ###
*.iml
*.ipr
modules.xml
.idea/
cmake-build-*/
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Java ###
*.class
*.log
*.ctxt
.mtj.tmp/
*.jar
!gradle-wrapper.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
### Mercurial ###
.hgignore
.hg/
### VSCode/Calva ###
.calva/
.clj-kondo/
.lsp/
### Misc ###
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build
/local/*.hprof
gradle/wrapper/gradle-wrapper.properties
View file @
bb55e9d7
distributionBase
=
GRADLE_USER_HOME
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-7.
5.1
-bin.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-7.
6
-bin.zip
zipStoreBase
=
GRADLE_USER_HOME
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
zipStorePath
=
wrapper/dists
src/main/java/jonathan/poalses/Server.java
View file @
bb55e9d7
...
@@ -4,6 +4,7 @@ package jonathan.poalses;
...
@@ -4,6 +4,7 @@ package jonathan.poalses;
import
java.io.*
;
import
java.io.*
;
import
java.net.*
;
import
java.net.*
;
import
java.util.concurrent.Executors
;
// Server class
// Server class
public
class
Server
{
public
class
Server
{
...
@@ -16,33 +17,32 @@ public class Server {
...
@@ -16,33 +17,32 @@ public class Server {
}
}
private
static
void
handle
(
ServerSocket
serverSocket
)
throws
IOException
{
private
static
void
handle
(
ServerSocket
serverSocket
)
throws
IOException
{
while
(
true
)
{
try
(
var
executor
=
Executors
.
newCachedThreadPool
())
{
Socket
socket
=
null
;
while
(
true
)
{
Socket
socket
=
null
;
try
{
try
{
// socket object to receive incoming client requests
// socket object to receive incoming client requests
socket
=
serverSocket
.
accept
();
socket
=
serverSocket
.
accept
();
System
.
out
.
println
(
"A new client is connected : "
+
socket
);
System
.
out
.
println
(
"A new client is connected : "
+
socket
);
// input and output streams
// input and output streams
DataInputStream
inputStream
=
new
DataInputStream
(
socket
.
getInputStream
());
DataInputStream
inputStream
=
new
DataInputStream
(
socket
.
getInputStream
());
DataOutputStream
outputStream
=
new
DataOutputStream
(
socket
.
getOutputStream
());
DataOutputStream
outputStream
=
new
DataOutputStream
(
socket
.
getOutputStream
());
System
.
out
.
println
(
"Assigning new thread for this client"
);
System
.
out
.
println
(
"Assigning new thread for this client"
);
outputStream
.
writeUTF
(
"{Server} Connection Successful\n"
);
outputStream
.
writeUTF
(
"{Server} Connection Successful\n"
);
// create a new thread object
// Create a server thread
Thread
thread
=
new
Thread
(
new
ServerThread
(
socket
,
inputStream
,
outputStream
));
executor
.
submit
(
new
ServerThread
(
socket
,
inputStream
,
outputStream
));
// Invoking the start() method
}
catch
(
Exception
e
)
{
thread
.
start
();
if
(
socket
!=
null
)
{
socket
.
close
();
}
catch
(
Exception
e
)
{
}
if
(
socket
!=
null
)
{
e
.
printStackTrace
();
socket
.
close
();
}
}
e
.
printStackTrace
();
}
}
}
}
}
}
...
...
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