Skip to content

Commit

Permalink
renamed file to fix dependency and library imports
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzke committed Nov 4, 2019
1 parent 79b8216 commit f41a298
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions socket_py/socket.py → socket_py/socket_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# websockets
import websockets
import asyncio
from socket import socket, AF_INET, SOCK_DGRAM
from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_BROADCAST, gethostbyname, gethostname

# utility libraries
import operator
Expand All @@ -22,6 +22,7 @@
import json
from json import JSONDecodeError
import credentials
from time import sleep

DEBUG = False

Expand All @@ -41,6 +42,9 @@
window = None
app = None

# broadcast port and ID
PORT = 50000
ID = "smartsocket"

class State(Enum):
disconnected = 0
Expand Down Expand Up @@ -97,14 +101,6 @@ def terminateThread(self, process):
# thread was not created yet
pass

def connectWS(self):
self.updateInfoCenter('')
self.updateInfo('Searching for smart sockets...')

# start websocket
self.ws_thread = WSConnection()
self.ws_thread.start()


# ethereum node functionality
class Node(QThread):
Expand Down Expand Up @@ -148,7 +144,14 @@ def __init__(self, parent=window):
self.threadActive = False

def run(self):
pass
s = socket(AF_INET, SOCK_DGRAM) # create UDP socket
s.bind(('', 0))
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) # this is a broadcast socket
while 1:
data = ID
s.sendto(data.encode('utf-8'), ('<broadcast>', PORT))
print("sent service announcement")
sleep(1)


def main():
Expand Down

0 comments on commit f41a298

Please sign in to comment.