SeattleTestbed / repy_v2

Seattle Testbed's Repy ("Restricted Python") sandbox, version 2
MIT License
12 stars 50 forks source link

UDPServerSocket getmessage erroneously raises LocalIPChanged #2

Closed choksi81 closed 10 years ago

choksi81 commented 10 years ago

Without changing my IP I get:


Following is a full traceback, and a user traceback. The user traceback excludes non-user modules. The most recent call is displayed last.

Full debugging traceback: "librepysocket", line 395, in accept_waiting "/Users/adadgar/Projects/seattle/branches/repy_v2/test/namespace.py", line 909, in __do_func_call "/Users/adadgar/Projects/seattle/branches/repy_v2/test/namespace.py", line 1161, in wrapped_function "/Users/adadgar/Projects/seattle/branches/repy_v2/test/emulcomm.py", line 1981, in getmessage

User traceback: "librepysocket", line 395, in accept_waiting

Exception (with class 'exception_hierarchy.LocalIPChanged'): The local ip 192.168.0.100 is no longer present on a system interface.

choksi81 commented 10 years ago

Author: vijay In FutureRepyAPI sendmessage call no longer raises the LocalIPChanged exception. When tried changing the IPaddress after UDPserver is up and listening,getmessage() will raise SocketWouldBlockError which is appropriate.

choksi81 commented 10 years ago

Author: justinc Why is this a good exception to raise? How does the programmer know what happened? It seems really odd to raise this exception here....

choksi81 commented 10 years ago

Author: vijay When an IP address of the system is changed a simple TCP and UDP server listening on the system will continue to listen on the old IP address (and port), and the operating system does not appear to notify the socket or the program that its IP address changed. I observed that listening on and then disconnecting the ethernet interface would raise a SocketWouldBlockError (Repyv2).

A possible solution to make the server program learn about the changed IP address would be to run another program or script that checks if the IP address changed and notifies the server program periodically about the change. Another solution would be to include the same piece of code in the server program itself. It appears that the Shims may have this capability.

UDP:

When an IP address of the system is changed a simple UDP server continue to be binded old IP,port and server will raise a SocketWouldBlockError.