@@ -97,7 +97,7 @@ def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, sockn
97
97
98
98
self ._socknum = _the_interface .get_socket (SOCKETS )
99
99
SOCKETS .append (self ._socknum )
100
- self .settimeout (1 )
100
+ self .settimeout (self . _timeout )
101
101
102
102
@property
103
103
def socknum (self ):
@@ -144,6 +144,7 @@ def connect(self, address, conntype=None):
144
144
assert conntype != 0x03 , "Error: SSL/TLS is not currently supported by CircuitPython."
145
145
host , port = address
146
146
147
+ print (address )
147
148
if hasattr (host , 'split' ):
148
149
host = tuple (map (int , host .split ('.' )))
149
150
if not _the_interface .socket_connect (self .socknum , host , port , conn_mode = self ._sock_type ):
@@ -164,7 +165,7 @@ def recv(self, bufsize=0): #pylint: disable=too-many-branches
164
165
"""Reads some bytes from the connected remote address.
165
166
:param int bufsize: Maximum number of bytes to receive.
166
167
"""
167
- # print("Socket read", bufsize)
168
+ print ("Socket read" , bufsize )
168
169
if bufsize == 0 :
169
170
# read everything on the socket
170
171
while True :
@@ -186,24 +187,31 @@ def recv(self, bufsize=0): #pylint: disable=too-many-branches
186
187
return ret
187
188
stamp = time .monotonic ()
188
189
190
+
189
191
to_read = bufsize - len (self ._buffer )
190
192
received = []
191
193
while to_read > 0 :
194
+ print ("Bytes to read:" , to_read )
192
195
if self ._sock_type == SOCK_STREAM :
193
196
avail = self .available ()
194
197
elif self ._sock_type == SOCK_DGRAM :
195
198
avail = _the_interface .udp_remaining ()
199
+ #print('Bytes Avail: ', avail)
196
200
if avail :
197
201
stamp = time .monotonic ()
198
202
if self ._sock_type == SOCK_STREAM :
203
+ print ("to_read: {}\n avail:{}\n " .format (to_read , avail ))
199
204
recv = _the_interface .socket_read (self .socknum , min (to_read , avail ))[1 ]
200
205
elif self ._sock_type == SOCK_DGRAM :
201
206
recv = _the_interface .read_udp (self .socknum , min (to_read , avail ))[1 ]
207
+ print ('RCV: ' , recv )
208
+ recv = bytes (recv )
202
209
received .append (recv )
203
210
to_read -= len (recv )
204
211
gc .collect ()
205
212
if self ._timeout > 0 and time .monotonic () - stamp > self ._timeout :
206
213
break
214
+ print ("{}, \n Type:{}" .format (received , type (received )))
207
215
self ._buffer += b'' .join (received )
208
216
209
217
ret = None
0 commit comments