Jan-10-2020, 03:44 PM
I am building a matching set of utilities to provide text transmission between two computers on the same network.
I started with sample code from a python cookbook. There is a sender and receiver code base that function in their role.
I have made some improvements and modifications to the code that make it more useful to the environment where this is to be used.
The code works perfectly when it is functioning strictly on the Python 3.6 interpreter.
When I freeze it with cx_freeze, both companion programs build fine. The strange thing is that that sender executes works perfectly while the receiver bombs out.
Here is the Traceback for your reference:
Any insight in this problem would be greatly appreciated and feel free to use this code for your own purpose. As I said, the py version works like a charm.
Receiver.py - Written for Python 3.6 windows
I started with sample code from a python cookbook. There is a sender and receiver code base that function in their role.
I have made some improvements and modifications to the code that make it more useful to the environment where this is to be used.
The code works perfectly when it is functioning strictly on the Python 3.6 interpreter.
When I freeze it with cx_freeze, both companion programs build fine. The strange thing is that that sender executes works perfectly while the receiver bombs out.
Here is the Traceback for your reference:
Error:Traceback (most recent call last):
File "C:\Python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 40, in run
module.run()
File "C:\Python\lib\site-packages\cx_Freeze\initscripts\Console.py", line 37, in run
exec(code, {'__name__': '__main__'})
File "Receiver.py", line 24, in <module>
OSError: [WinError 10049] The requested address is not valid in its context
Below are both my sender.py and receiver.py. The portion that is breaking in the receiver executable is identical to what is used in the sender (except for IP address, which is valid).Any insight in this problem would be greatly appreciated and feel free to use this code for your own purpose. As I said, the py version works like a charm.
Receiver.py - Written for Python 3.6 windows
import os import sys import subprocess from socket import * subprocess.call("cls", shell=True) theargis = '' if len(sys.argv) > 1: theargis +=str(sys.argv[1]) if theargis > '': host = theargis print ("Using Client Address of: " + theargis) else: host = "53.68.241.25" print ("Using Default Address!") port = 13000 buf = 1024 addr = (host, port) UDPSock = socket(AF_INET, SOCK_DGRAM) UDPSock.bind(addr) print ("Waiting to receive messages...") while True: (data, addr) = UDPSock.recvfrom(buf) print ("Production number: " + data.decode("utf-8")) if data.decode("utf-8").upper() == "EXIT": break UDPSock.close() os._exit(0)Sender.py - Written for Python 3.6 windows
import os import sys import subprocess from socket import * subprocess.call("cls", shell=True) theargis = '' if len(sys.argv) > 1: theargis +=str(sys.argv[1]) if theargis > '': host = theargis print ("Using Server Address of: " + theargis) else: host = "53.68.240.47" print ("Using Default Address!") port = 13000 addr = (host, port) UDPSock = socket(AF_INET, SOCK_DGRAM) while True: data = input("Enter message to send or type 'EXIT': ") bytes = data.encode() UDPSock.sendto(bytes, addr) if data.upper() == "EXIT": break UDPSock.close() os._exit(0)