# Socket Connection Read Data as Byte Array

**URL:** <https://forum.inductiveautomation.com/t/socket-connection-read-data-as-byte-array/9533>\
**Category:** Ignition\
**Created:** [January 12, 2015, 11:07pm UTC](https://forum.inductiveautomation.com/t/socket-connection-read-data-as-byte-array/9533 "2015-01-12T23:07:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DNP3](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@DNP3](https://forum.inductiveautomation.com/u/DNP3)\
**Post date:** [January 12, 2015, 11:07pm UTC](https://forum.inductiveautomation.com/t/socket-connection-read-data-as-byte-array/9533/1 "2015-01-12T23:07:44Z")

</div>

I’m trying to create a socket connection and read the buffer as an array of bytes. The socket connection works fine. So performering a simple socket.recv (returns a string) works fine, however, when I perform a socket.recv\_into (reads buffer as array of bytes) it doesn’t work. The error seems to indicate that socket.recv\_into isn’t included in the library. Any advice would be appreciated.

import socket  
IP = ‘localhost’  
Port = 4103  
buff = 100  
s = socket.socket(socket.AF\_INET,socket.SOCK\_STREAM)  
s.connect((IP,Port))  
#nbytes = s.recv\_into(data) [color=#0000FF]#This doesnt work[/color]  
data = s.recv(buff) [color=#0000FF] #This WORKS![/color]  
s.close()

print nbytes

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 12, 2015, 11:30pm UTC](https://forum.inductiveautomation.com/t/socket-connection-read-data-as-byte-array/9533/2 "2015-01-12T23:30:16Z")

</div>

Despite Python’s more current documentation claiming recv\_into is ‘New in version 2.5’, I think it’s actually new in 2.6. If you look at the old 2.5 documentation there is no recv\_into.

[docs.python.org/release/2.5/lib … jects.html](https://docs.python.org/release/2.5/lib/socket-objects.html)

---

<div class="post-metadata">

**Author:** ![DNP3](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@DNP3](https://forum.inductiveautomation.com/u/DNP3)\
**Post date:** [January 13, 2015, 12:01pm UTC](https://forum.inductiveautomation.com/t/socket-connection-read-data-as-byte-array/9533/3 "2015-01-13T12:01:18Z")

</div>

Are there plans to update the Python library to a more current version? Timeline?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 13, 2015, 3:40pm UTC](https://forum.inductiveautomation.com/t/socket-connection-read-data-as-byte-array/9533/4 "2015-01-13T15:40:23Z")

</div>

Until recently there hasn’t even been a new version to update to, but it looks like Jython 2.7 is nearing a release, so maybe we can update to that in the future.

It’s not scheduled at all right now, so in all likelihood the earliest you’d see it would be something like Ignition 7.9.

(the Jython project lags significantly behind Python: [jython.org](http://www.jython.org))
