Display local IP address

From IronPython Cookbook

(Difference between revisions)
Line 4: Line 4:
import socket
import socket
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Windows.Forms")
-
 
+
from System.Windows.Forms import MessageBox
-
from System.Windows.Forms import Application, MessageBox
+
   
   
-
MessageBox.Show(socket.gethostbyname(socket.gethostname()))
+
address = socket.gethostbyname(socket.gethostname())
-
Application.Run()
+
MessageBox.Show(address)
</pre>
</pre>

Revision as of 17:59, 13 July 2009

Showing the local IP address:

import clr
import socket
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import MessageBox
 
address = socket.gethostbyname(socket.gethostname())
MessageBox.Show(address)

Originally by Domingo Aguilera.


Return to Contents.

TOOLBOX
LANGUAGES