Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Samuel Kemmler
FA Server Client
Commits
7c75c32c
Commit
7c75c32c
authored
Sep 06, 2021
by
Samuel Kemmler
Browse files
Initial commit
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
client.py
0 → 100644
View file @
7c75c32c
#
# Hello World client in Python
# Connects REQ socket to tcp://localhost:5555
# Sends "Hello" to server, expects "World" back
#
import
zmq
context
=
zmq
.
Context
()
# Socket to talk to server
print
(
"Connecting to hello world server…"
)
socket
=
context
.
socket
(
zmq
.
REQ
)
socket
.
connect
(
"tcp://192.168.2.110:5555"
)
# Do 10 requests, waiting each time for a response
for
request
in
range
(
10
):
print
(
"Sending request %s …"
%
request
)
socket
.
send
(
b
"Hello"
)
# Get the reply.
message
=
socket
.
recv
()
server.py
0 → 100644
View file @
7c75c32c
#
# Hello World server in Python
# Binds REP socket to tcp://*:5555
# Expects b"Hello" from client, replies with b"World"
#
import
time
import
zmq
context
=
zmq
.
Context
()
socket
=
context
.
socket
(
zmq
.
REP
)
socket
.
bind
(
"tcp://*:5555"
)
while
True
:
# Wait for next request from client
message
=
socket
.
recv
()
print
(
"Received request: %s"
%
message
)
# Do some 'work'
time
.
sleep
(
1
)
# Send reply back to client
socket
.
send
(
b
"World"
)
Write
Preview
Supports
Markdown
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