Python Forum
tcp python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: Networking (https://python-forum.io/Forum-Networking)
+--- Thread: tcp python (/Thread-tcp-python)



tcp python - Michele83 - Oct-17-2020

hello
i want with python send message to server
I want to send messages to the server even if the server is not sending anything to the clients
or both together
I have tried with this
but if the server does not send anything to the client I cannot send anything
There is a solution?
this is the code i tried
import socket
host ='192.168.1.15'
port = 123
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM
s.connect(('192.168.1.15', port))
s.send(b'CONNECT|Prova*')
while True:
    s.send(b'SERVER|Prova*')
while True:
    msg=s.recv(1024)
    print('Recived: ' + msg.decode())
    msg = s.recv(1024)
thank you