-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServidor.py
More file actions
34 lines (31 loc) · 1.04 KB
/
Servidor.py
File metadata and controls
34 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import socket
import os
def cliente():
for i in range(1):
msg = input("> ")
envio = str.encode(msg)
serverAddressPort = ("10.15.135.16", 20010)
bufferSize = 1024
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
UDPClientSocket.sendto(envio, serverAddressPort)
UDPClientSocket.recvfrom(bufferSize)
def server():
bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
message = bytesAddressPair[0]
address = bytesAddressPair[1]
Player = f"Menssagem | {message}"
print(Player)
UDPServerSocket.sendto(bytesToSend, address)
localIP = "10.15.135.16"
localPort = 20001
bufferSize = 1024
msgFromServer = "Hello UDP Client"
bytesToSend = str.encode(msgFromServer)
UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
UDPServerSocket.bind((localIP, localPort))
os.system('cls')
print(" SERVER IMAGEM ONLINE !")
print()
while(True):
server()
cliente()