RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
Net.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
5 # Copyright 2015 RAPP
6 
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 
11  #http://www.apache.org/licenses/LICENSE-2.0
12 
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 
19 # Authors: Konstantinos Panayiotou, Manos Tsardoulias
20 # contact: klpanagi@gmail.com, etsardou@iti.gr
21 
22 
23 ## @file Utils/Net.py
24 #
25 # @copyright Rapp Projecty EU 2016
26 # @author Konstantinos Panayiotou, [klpanagi@gmail.com]
27 #
28 
29 import socket
30 
31 class Net(object):
32  """ Provide Network related static methods """
33 
34  ## Hacky method to get the actual public ip.
35  #
36  @staticmethod
38  """! Prepare a dummy socket to google.com and see what the socket name is.
39 
40  @return string - The ipv4 address of the machine.
41  """
42 
43  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
44  s.connect(('google.com', 0))
45  ipaddr = s.getsockname()[0]
46  return ipaddr
def ipaddr_connected
Hacky method to get the actual public ip.
Definition: Net.py:37