这是我的代码:
import serial
import time
import socket
ip = str('url')
port = int(6090)
err = 0
try:
mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mySocket.connect((ip, port))
while 1:
arduino = serial.Serial('/dev/ttyACM0', 9600)
sensorValue = arduino.readline()
mySocket.sendall(sensorValue)
except socket.error, msg:
mySocket.close()
print 'socket error', msg
mySocket.close
运行此程序后,我收到此消息“套接字错误[Errno -3]名称解析暂时失败”。 有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
根本问题是import ctypes
libc = ctypes.cdll.LoadLibrary('libc.so.6')
res_init = libc.__res_init
res_init()
只能在python启动时读取。要强制刷新解析表,可以运行它(在linux上):
import React from 'react';
var Albums = React.createClass({
render() {
return (
<ul id="frames_list">
{this.props.frames.map(function(frames){
return (
<li key={frames.frameId}>
<Link to="/frames" >{frames.frameName}</Link>
</li>
)
}.bind(this))}
</ul>
)
}
});
module.exports = Albums;