in udp client
sk = socket( AF_INET , SOCK_DGRAM )
host = 'you know receive's ip address'
port = 'you know receive's port'
message = 'whatever'
sk.sendto( message , ( host , port ) )
in udp receiver
message, clientAddress = serverSocket.recvfrom(2048)
i know clientAddress contains a pair which is client's ip and port number.
but that is because in client, the system will add a header in the message that contains itself(client) own ip and port, while running since in each computer, the ip and port of client may be differnent
but in client how do i know its ip and port before sendto(). When someone runs python client
in a computer, which function should i use to know the actual ip and port of this compouter
any help would be much appreciated thankyou
Aucun commentaire:
Enregistrer un commentaire