Reputation: 764
I want to be able to send IP notifications through TCP to a server with a specific string.
The idea behind the project is this: I have a camera that saves a picture on event (like movement) in a folder and I have a watchdog sort of program that watches that directory for changes i.e new files. I need this script to send the path to the picture through local network to the server that has a listener
on that port 34000
.
How can I achieve this?
The code I have right now is this (in the example I send 10 times the same message):
import byte
import socket
host = 'ip.of.the.host'
port = 34000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
for i in range(10):
message = bytes('some message', 'utf-8')
s.send(message)
s.close()
Here I have the error :
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Upvotes: 0
Views: 310
Reputation: 77
The error is raised because the socket is not open, it's similar to this python socket programming OSError: [WinError 10038] an operation was attempted on something that is not a socket
Upvotes: 1