# Python xbee node to\_socket\_addr() method returning too many/zero-value fields

**URL:** <https://forums.digi.com/t/python-xbee-node-to-socket-addr-method-returning-too-many-zero-value-fields/22053>\
**Category:** Python\
**Tags:** socket, python, xbee3\
**Created:** [December 14, 2020, 9:04am UTC](https://forums.digi.com/t/python-xbee-node-to-socket-addr-method-returning-too-many-zero-value-fields/22053 "2020-12-14T09:04:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![starfish](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@starfish](https://forums.digi.com/u/starfish)\
**Post date:** [December 14, 2020, 9:04am UTC](https://forums.digi.com/t/python-xbee-node-to-socket-addr-method-returning-too-many-zero-value-fields/22053/1 "2020-12-14T09:04:06Z")

</div>

Hi,

Trying to make some sense of why I’m not able to communicate with devices.

(This is after disabling xbgw\_main.py so I can muck around in the REPL.)

\>\>\> n

\>\>\> n.profile\_id  
49413  
\>\>\> n.to\_socket\_addr()  
(‘[00:13:a2:00:41:b4:c8:e0]!’, 0, 0, 0, 0, 0, 0)

When I try to use this address tuple in sendto, socket complains that there are too many args (there are 7 instead of 6).

But more visibly, none of the endpoint/profile/whatever fields are populated-- yet they exist as attributes on the node object itself.

Is this method completely broken? Or am I doing something wrong?

Thanks!

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [December 14, 2020, 10:13am UTC](https://forums.digi.com/t/python-xbee-node-to-socket-addr-method-returning-too-many-zero-value-fields/22053/2 "2020-12-14T10:13:59Z")

</div>

You look to be doing this wrong.  
It should be more like:

xbee\_sd.sendto(“Hello, World!”, 0, (‘[00:13:a2:00:40:0a:07:a5]!’, 0xe8, 0xc105, 0x11, 0, 0x42))

---

<div class="post-metadata">

**Author:** ![starfish](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@starfish](https://forums.digi.com/u/starfish)\
**Post date:** [December 21, 2020, 9:30am UTC](https://forums.digi.com/t/python-xbee-node-to-socket-addr-method-returning-too-many-zero-value-fields/22053/3 "2020-12-21T09:30:16Z")

</div>

Turns out I was doing it wrong after all.

That method requires additional args but does not complain if they are not provided.

```auto
endpoint=0xe8
profile_id=49413
cluster_id=0x11
nodes = xbee.get_node_list()
node = n = nodes[1]

# --- here's where i went wrong ---
addr = n.to_socket_addr(endpoint, profile_id, cluster_id)[:-1]
# --- end of incompetence ---

sd = socket(AF_XBEE, SOCK_DGRAM, XBS_PROT_TRANSPORT)
sd.bind(('', endpoint, profile_id, cluster_id))
cmd = 
sd.sendto(cmd, 0, addr)

```
