Need some help on the tcp server example in the IoT SDK.
All steps working but the python script gets Connection refused.
bash# ifconfig bt0
bt0 Link encap:UNSPEC HWaddr B8-27-EB-FF-FE-1A-A7-41-00-00-00-00-00-00-00-00
inet6 addr: fe80::ba27:ebff:fe1a:a741/64 Scope:Link
inet6 addr: 2001::ba27:ebff:fe1a:a741/64 Scope:Global
inet6 addr: 2004::ba27:ebff:fe1a:a741/64 Scope:Global
UP POINTOPOINT RUNNING MULTICAST MTU:1280 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:286 (286.0 B) TX bytes:1893 (1.8 KB)
bash# ping6 2004::ba27:ebff:fe1a:a741
PING 2004::ba27:ebff:fe1a:a741(2004::ba27:ebff:fe1a:a741) 56 data bytes
64 bytes from 2004::ba27:ebff:fe1a:a741: icmp_seq=1 ttl=64 time=0.170 ms
64 bytes from 2004::ba27:ebff:fe1a:a741: icmp_seq=2 ttl=64 time=0.166 ms
64 bytes from 2004::ba27:ebff:fe1a:a741: icmp_seq=3 ttl=64 time=0.168 ms
^C
--- 2004::ba27:ebff:fe1a:a741 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.166/0.168/0.170/0.001 ms
bash# python tcp_c2
Traceback (most recent call last):
File "tcp_c2", line 9, in <module>
sock.connect((SERVER_ADDR, SERVER_PORT))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused
bash# cat tcp_c2
import socket
import struct
-#This example assumes the server BD address to be 00:AA:BB:CC:DD:EE and the used global prefix to be 2004::/64.
-#Therefore the global IPv6 address of the server will be 2004::02AA:BBFF:FECC:DDEE.
SERVER_ADDR = '2004::ba27:ebff:fe1a:a741'
SERVER_PORT = 9000
sequence_number = 1
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.connect((SERVER_ADDR, SERVER_PORT))
while sequence_number < 101 :
data = struct.pack("!I", sequence_number)
data += 'Ping'
sock.sendto(data, (SERVER_ADDR, SERVER_PORT, 0, 0))
recv_data = sock.recvfrom(8)
print recv_data
rx_sequence_number = struct.unpack("!I", recv_data[0][:4])[0]
if sequence_number is not rx_sequence_number:
print "Sequence number mismatch!"
sequence_number+= 1
sock.close()
Output from device:
[APPL]: Port Setup.
[APPL]: Init done.
[APPL]: Physical layer in connectable mode.
[APPL]: Physical layer: connected.
[APPL]: IPv6 interface up.