Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Phillip Seo
/
project1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a132e579
authored
Jan 21, 2021
by
Phillip Seo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
5782422f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
echo_server.py
echo_server.py
0 → 100644
View file @
a132e579
import
socket
import
sys
#using TCP socket
serversocket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
#accepting server port and only command-line argument
port
=
int
(
sys
.
argv
[
1
])
serversocket
.
bind
((
'localhost'
,
port
))
serversocket
.
listen
(
5
)
#infinite loop to wait for incoming connections from client
while
True
:
#accept incoming connection
conn
,
client
=
serversocket
.
accept
()
#read in text from connection
text
=
conn
.
recv
(
100
)
#print text to STDOUT
print
(
text
.
decode
())
#send text back to client
conn
.
sendall
(
text
)
#close connection
conn
.
close
()
\ 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