python error: TypeError: bind() takes exactly one argument (2 given)
python code is here.
import socket
import time
import re
import cv2
from time import sleep
import struct
import numpy as np
import matlab
import json
class matserver:
ip='127.0.0.1'
port=12345
def __init__(self,ip,port):
self.ip = ip # 受信元IP
self.port = port # 受信元ポート番号
self.SrcAddr = (self.ip, self.port) # アドレスをtupleに格納
self.BUFSIZE = 1024 # バッファサイズ指定
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # ソケット作成
self.sock.bind(self.SrcAddr) # 受信元アドレスでバインド
def start_listening(self,callback=None):
try :
# ③Clientからのmessageの受付開始
#print('Waiting message')
message, cli_addr = self.sock.recvfrom(self.BUFSIZE)
message = message.decode(encoding='utf-8')
#print(f'Received message is [{message}]')
d = re.findall(r"[-+]?\d*\.\d+|\d+", message)
a = np.frombuffer(d, dtype=np.uint8, offset=8)
return a
#print(d)
# Clientが受信待ちになるまで待つため
#time.sleep(1)
# ④Clientへ受信完了messageを送信
#print('Send response to Client')
#sock.sendto('Success to receive message'.encode(encoding='utf-8'), cli_addr)
except KeyboardInterrupt:
self.sock.close()
return False # クラス呼び出し # 関数実行
I run matserver in matlab. error. why?