Skip to content
Snippets Groups Projects
Commit ea3f8092 authored by Julien David's avatar Julien David
Browse files

Merge branch '002-AddingClient' into 'master'

002 adding client

See merge request !2
parents c86389e5 2e81719f
No related branches found
No related tags found
1 merge request!2002 adding client
# Authors : Julien DAVID & Ismail MOUMNI
import socket
__RDOS_Port__= 9393
__RDOS_Host__='127.0.0.1'
# Function server_conn creates a socket and connects it to server
# Function server_conn take No arguments
# Function returns a socket after making connexion
def server_conn(host,port):
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_message(conn: socket, message: str):
data = ""
if len(message)!=0:
conn.send(bytes(message,"utf-8"))
data = conn.recv(1024)
return data
# Function run_client connects client to server by socket
# Function run_client takes 3 parameters -Host : IP ADDRESS OF SERVER -Port : Server PORT -MESS:Message sent to the server
# Function run_Client returns the state of the server
def run_client(Host, Port, message : str):
s = server_conn(Host,Port)
print("Starting connexion to server on Port :", Port)
recv = send_message(s,message)
print("Message ENVOYÉ : ",recv)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment