Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Multithreaded Math Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LAHTP Common
Multithreaded Math Server
Compare revisions
cd47e0578ab99840e966f0980b648b72815beebd to master
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
lahtp-common/multithreaded-math-server
Select target project
No results found
master
Select Git revision
Branches
master
Swap
Target
Adhiyaman/multithreaded-math-server
Select target project
lahtp-common/multithreaded-math-server
krithikramraja/multithreaded-math-server
SiddharthSanthosh/multithreaded-math-server
tharunvt/multithreaded-math-server
selva1011/multithreaded-math-server
Deepakkumar/multithreaded-math-server
ganesha005/multithreaded-math-server
revanth/multithreaded-math-server
Sriraman/multithreaded-math-server
Adhiyaman/multithreaded-math-server
tamil0323/multithreaded-math-server
sr_subin/multithreaded-math-server
Nirmalkumar/multithreaded-math-server
arunmozhi5284/multithreaded-math-server
ram_rogers/multithreaded-math-server
monish-palanikumar/multithreaded-math-server
Gokul_Krish_Nan/multithreaded-math-server
Sabarish/multithreaded-math-server
Karthik/multithreaded-math-server
Arivazhagan_S/multithreaded-math-server
Thamizhpathi/multithreaded-math-server
Pranesh/multithreaded-math-server
dhugeshwaran/multithreaded-math-server
Sherif7/multithreaded-math-server
shaik_sultan31/multithreaded-math-server
Thiru/multithreaded-math-server
rii/multithreaded-math-server
kalish/multithreaded-math-server
28 results
cd47e0578ab99840e966f0980b648b72815beebd
Select Git revision
Branches
master
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
Updated code with layer informations
· e6a40ad6
Sibidharan
authored
3 years ago
e6a40ad6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
comm_thread.py
+0
-35
0 additions, 35 deletions
comm_thread.py
math-server.py
+56
-5
56 additions, 5 deletions
math-server.py
process_thread.py
+0
-12
0 additions, 12 deletions
process_thread.py
with
56 additions
and
52 deletions
comm_thread.py
deleted
100644 → 0
View file @
cd47e057
class
MathServerCommunicationThread
(
Thread
):
def
__init__
(
self
,
conn
,
addr
):
Thread
.
__init__
(
self
)
self
.
conn
=
conn
self
.
addr
=
addr
def
run
(
self
):
print
(
"
{} connected with back port {}
"
.
format
(
self
.
addr
[
0
],
self
.
addr
[
1
]))
self
.
conn
.
sendall
(
"
Simple Math Server developed by LAHTP
\n\n
Give any math expressions, and I will answer you :)
\n\n
$
"
.
encode
())
p
=
Popen
([
'
bc
'
],
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
STDOUT
)
output
=
ProcessOutputThread
(
p
,
self
.
conn
)
output
.
start
()
while
not
p
.
stdout
.
closed
or
not
self
.
conn
.
_closed
:
try
:
data
=
self
.
conn
.
recv
(
1024
)
if
not
data
:
break
else
:
try
:
data
=
data
.
decode
()
query
=
data
.
strip
()
if
query
==
'
quit
'
or
query
==
'
exit
'
:
p
.
communicate
(
query
.
encode
(),
timeout
=
1
)
if
p
.
poll
()
is
not
None
:
break
query
=
query
+
'
\n
'
p
.
stdin
.
write
(
query
.
encode
())
p
.
stdin
.
flush
()
except
:
pass
except
:
pass
self
.
conn
.
close
()
This diff is collapsed.
Click to expand it.
math-server.py
View file @
e6a40ad6
import
socket
from
subprocess
import
Popen
,
STDOUT
,
PIPE
from
threading
import
Thread
from
comm_thread
import
MathServerCommunicationThread
from
comm_thread
import
ProcessOutputThread
HOST
=
''
PORT
=
4444
def
start_new_math_thread
(
conn
,
addr
):
t
=
MathServerCommunicationThread
(
conn
,
addr
)
t
.
start
()
class
ProcessOutputThread
(
Thread
):
#OOPS
def
__init__
(
self
,
proc
,
conn
):
Thread
.
__init__
(
self
)
self
.
proc
=
proc
self
.
conn
=
conn
def
run
(
self
):
while
not
self
.
proc
.
stdout
.
closed
and
not
self
.
conn
.
_closed
:
try
:
self
.
conn
.
sendall
(
self
.
proc
.
stdout
.
readline
())
except
:
pass
class
MathServerCommunicationThread
(
Thread
):
def
__init__
(
self
,
conn
,
addr
):
Thread
.
__init__
(
self
)
self
.
conn
=
conn
self
.
addr
=
addr
def
run
(
self
):
print
(
"
{} connected with back port {}
"
.
format
(
self
.
addr
[
0
],
self
.
addr
[
1
]))
self
.
conn
.
sendall
(
"
Simple Math Server developed by LAHTP
\n\n
Give any math expressions, and I will answer you :)
\n\n
$
"
.
encode
())
## APPLICATION LAYER 7
p
=
Popen
([
'
bc
'
],
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
STDOUT
)
output
=
ProcessOutputThread
(
p
,
self
.
conn
)
output
.
start
()
while
not
p
.
stdout
.
closed
or
not
self
.
conn
.
_closed
:
try
:
## PRESENTATION LAYER 6
data
=
self
.
conn
.
recv
(
1024
)
if
not
data
:
break
else
:
try
:
data
=
data
.
decode
()
query
=
data
.
strip
()
if
query
==
'
quit
'
or
query
==
'
exit
'
:
p
.
communicate
(
query
.
encode
(),
timeout
=
1
)
if
p
.
poll
()
is
not
None
:
break
query
=
query
+
'
\n
'
p
.
stdin
.
write
(
query
.
encode
())
p
.
stdin
.
flush
()
except
:
pass
except
:
pass
self
.
conn
.
close
()
HOST
=
''
PORT
=
3074
## SESSION LAYER 5
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
s
.
bind
((
HOST
,
PORT
))
...
...
@@ -19,3 +68,5 @@ while True: # To accept many incoming connections.
conn
,
addr
=
s
.
accept
()
# Open door
start_new_math_thread
(
conn
,
addr
)
s
.
close
()
This diff is collapsed.
Click to expand it.
process_thread.py
deleted
100644 → 0
View file @
cd47e057
class
ProcessOutputThread
(
Thread
):
#OOPS
def
__init__
(
self
,
proc
,
conn
):
Thread
.
__init__
(
self
)
self
.
proc
=
proc
self
.
conn
=
conn
def
run
(
self
):
while
not
self
.
proc
.
stdout
.
closed
and
not
self
.
conn
.
_closed
:
try
:
self
.
conn
.
sendall
(
self
.
proc
.
stdout
.
readline
())
except
:
pass
This diff is collapsed.
Click to expand it.