私はソケットについて知りたいと思っています。私はcan not ip、portに接続します。 これは私が得たスクリプトです:ソケットは-pythonに接続しようとするとエラーが表示されます
スティアンのソケット・テスト・ツール
import socket
print "send request to website to check if sockets work right"
ip = raw_input("website ip: ")
port = raw_input("website port: ")
socket.connect(ip, port)
tosend = "this is a test"
currVal = 0
while currVal < 1:
socket.send(tosend)
print "1 sockets sent..."
currrVal += 1
print "Done sending sockets. This hopefully worked"
はPythonコードに何か問題ありますか? これはipv4またはipv6でのみ機能しますか?または両方で動作しますか? IMはGETTING
ERROR:
C:\Users\Swipper\Documents\Python\sockets>sock.py
send request to website to check if sockets work right
website ip: 127.0.0.1
website port:
Traceback (most recent call last):
File "C:\Users\Swipper\Documents\Python\sockets\sock.py", line 8, in <modu
le>
socket.connect(ip, port)
AttributeError: 'module' object has no attribute 'connect'
誰かが答えを知っている願っています。
PS:私はpython 2.7を使用します。
-stian
あなたの質問は曖昧です。取得した正確なエラーを含めてください。 –