Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
simpletcpecho
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Doug Harms
simpletcpecho
Commits
2c9b50e1
Commit
2c9b50e1
authored
2 years ago
by
Doug Harms
Browse files
Options
Downloads
Patches
Plain Diff
Changed command line arguments
parent
ffa18263
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client.py
+9
-1
9 additions, 1 deletion
client.py
server.py
+9
-2
9 additions, 2 deletions
server.py
with
18 additions
and
3 deletions
client.py
+
9
−
1
View file @
2c9b50e1
...
...
@@ -5,7 +5,15 @@ import sys
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
# Connect the socket to the port where the server is listening
server_address
=
(
'
localhost
'
,
10000
)
# process command line arguments
argc
=
len
(
sys
.
argv
)
if
argc
!=
3
:
print
(
"
usage: python3 client.py serverAddress serverPort
"
)
sys
.
exit
()
serverName
=
sys
.
argv
[
1
]
port
=
int
(
sys
.
argv
[
2
])
server_address
=
(
serverName
,
port
)
print
(
'
connecting to {} port {}
'
.
format
(
server_address
[
0
],
server_address
[
1
])
)
sock
.
connect
(
server_address
)
...
...
This diff is collapsed.
Click to expand it.
server.py
+
9
−
2
View file @
2c9b50e1
...
...
@@ -4,8 +4,15 @@ import sys
# Create a TCP/IP socket
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
# process command line arguments
argc
=
len
(
sys
.
argv
)
if
argc
!=
2
:
print
(
"
usage: python3 server.py serverPort
"
)
sys
.
exit
()
port
=
int
(
sys
.
argv
[
1
])
# Bind the socket to the port
server_address
=
(
'
localhost
'
,
10000
)
server_address
=
(
'
'
,
port
)
print
(
'
starting up on {} port {}
'
.
format
(
server_address
[
0
],
server_address
[
1
]))
sock
.
bind
(
server_address
)
...
...
@@ -19,7 +26,7 @@ while True:
connection
,
client_address
=
sock
.
accept
()
print
(
'
connection from {}
'
.
format
(
client_address
))
# Receive the data in small chunks and retransmit it. Continue doing this
# until the client closes the tcp connection
while
True
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment