Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rdos-python
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Julien David
rdos-python
Merge requests
!1
WIP - 002 - adding client for server
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WIP - 002 - adding client for server
002--Adding-Client-for-server
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Closed
Ismail Moumni
requested to merge
002--Adding-Client-for-server
into
master
4 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
Adding Client to test the server
0
0
Merge request reports
Viewing commit
671b26c2
Show latest version
1 file
+
38
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
671b26c2
Client File
· 671b26c2
Ismail Moumni
authored
4 years ago
client.py
0 → 100644
+
38
−
0
Options
# Author : Ismail MOUMNI
import
socket
Port
=
9393
Host
=
'
127.0.0.1
'
# Function server_conn creates a socket and connects it to server
# Function server_conn take No arguments and returns socket
def
server_conn
():
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
connect
((
Host
,
Port
))
return
s
# send_mess Function that return a message from a server to a client connexion
# Function takes 2 parameters (Socket & Message )
# Function Output message send from server
def
send_mess
(
conn
,
mess
):
data
=
""
if
len
(
mess
)
!=
0
:
conn
.
send
(
bytes
(
mess
,
"
utf-8
"
))
data
=
conn
.
recv
(
1024
)
return
data
# Function run takes 3 arguments and connects with server
def
run
(
Host
,
Port
,
mess
):
s
=
server_conn
()
print
(
"
Starting connexion to server on Port :
"
,
Port
)
recv
=
send_mess
(
s
,
mess
)
print
(
b
"
Message ENVOYÉ :
"
,
recv
)
run
(
'
127.0.0.1
'
,
Port
,
"
Hey there how are you!!
"
)
\ No newline at end of file
Loading