Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- #SERVER = server side code
- #CLIENT = client side code
- server_address = ('ip', int(port))
- tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- #tcp.connect(server_address) #CLIENT
- tcp.bind(server_address)#SERVER
- try:
- tcp.listen(1) #SERVER
- connection, client = tcp.accept() #SERVER
- print(connection, client) #SERVER
- connection.send("hello World") #SERVER
- recieved = ""
- while recieved == "":
- recieved = connectioin.recv() #SERVER
- #recieved = tcp.recv() #CLIENT
- print(recieved)
- except KeyboardInterrupt:
- print("quitting")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement