Skip to content
Snippets Groups Projects
Commit f0fa3b2f authored by SBAIHI Dylan's avatar SBAIHI Dylan
Browse files

Upload New File

parent 51c4e8c0
Branches
No related tags found
No related merge requests found
import socket
import json
class TCPClient:
def __init__(self, host, port):
self.host = host
self.port = port
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.client_socket.connect((host, port))
def send_request(self, request):
self.client_socket.send(request.encode('utf-8'))
response = self.client_socket.recv(4096).decode('utf-8')
return response
def close(self):
self.client_socket.close()
# Utilisation de la classe TCPClient
if __name__ == "__main__":
client_instance = TCPClient('localhost', 50000)
sql_query = {
'request': 'get_user_by_username_password',
'params': ('dydy', 'mdp')
}
message = json.dumps(sql_query)
client_instance.send_request(message)
client_instance.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment