This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#server | |
# TCP Server Code | |
#host="127.0.0.1" # Set the server address to variable host | |
host="127.168.2.75" # Set the server address to variable host | |
port=4446 # Sets the variable port to 4444 | |
from socket import * # Imports socket module | |
s=socket(AF_INET, SOCK_STREAM) | |
s.bind((host,port)) # Binds the socket. Note that the input to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP | |
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
client.bind(("", 37020)) | |
while True: | |
data, addr = client.recvfrom(1024) | |
print("received message: %s"%data) |