def putline(self, line):
line = line + CRLF
if self.debugging > 1: print '*put*', self.sanitize(line)
- self.sock.send(line)
+ self.sock.sendall(line)
# Internal: send one command to the server (through putline())
def putcmd(self, line):
tried. Instead, just send the ABOR command as OOB data.'''
line = 'ABOR' + CRLF
if self.debugging > 1: print '*put urgent*', self.sanitize(line)
- self.sock.send(line, MSG_OOB)
+ self.sock.sendall(line, MSG_OOB)
resp = self.getmultiline()
if resp[:3] not in ('426', '226'):
raise error_proto, resp
while 1:
buf = fp.read(blocksize)
if not buf: break
- conn.send(buf)
+ conn.sendall(buf)
conn.close()
return self.voidresp()
if buf[-2:] != CRLF:
if buf[-1] in CRLF: buf = buf[:-1]
buf = buf + CRLF
- conn.send(buf)
+ conn.sendall(buf)
conn.close()
return self.voidresp()
port = int(port)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
- s.send(selector + CRLF)
+ s.sendall(selector + CRLF)
s.shutdown(1)
return s.makefile('rb')
if self.debuglevel > 0:
print "send:", repr(str)
try:
- self.sock.send(str)
+ self.sock.sendall(str)
except socket.error, v:
if v[0] == 32: # Broken pipe
self.close()
def send(self, data):
"""Send data to remote."""
- bytes = len(data)
- while bytes > 0:
- sent = self.sock.send(data)
- if sent == bytes:
- break # avoid copy
- data = data[sent:]
- bytes = bytes - sent
-
+ self.sock.sendall(data)
def shutdown(self):
"""Close I/O established in "open"."""
"""Internal: send one line to the server, appending CRLF."""
line = line + CRLF
if self.debugging > 1: print '*put*', `line`
- self.sock.send(line)
+ self.sock.sendall(line)
def putcmd(self, line):
"""Internal: send one command to the server (through putline())."""
def _putline(self, line):
if self._debugging > 1: print '*put*', `line`
- self.sock.send('%s%s' % (line, CRLF))
+ self.sock.sendall('%s%s' % (line, CRLF))
# Internal: send one command to the server (through _putline())
if self.debuglevel > 0: print 'send:', `str`
if self.sock:
try:
- sendptr = 0
- while sendptr < len(str):
- sendptr = sendptr + self.sock.send(str[sendptr:])
+ self.sock.sendall(str)
except socket.error:
self.close()
raise SMTPServerDisconnected('Server not connected')
def flush(self):
if self._wbuf:
- self._sock.send(self._wbuf)
+ self._sock.sendall(self._wbuf)
self._wbuf = ""
def fileno(self):
self.flush()
def writelines(self, list):
- filter(self._sock.send, list)
+ filter(self._sock.sendall, list)
self.flush()
def read(self, n=-1):
if IAC in buffer:
buffer = buffer.replace(IAC, IAC+IAC)
self.msg("send %s", `buffer`)
- self.sock.send(buffer)
+ self.sock.sendall(buffer)
def read_until(self, match, timeout=None):
"""Read until a given string is encountered or until timeout.
if self.option_callback:
self.option_callback(self.sock, c, opt)
else:
- self.sock.send(IAC + WONT + opt)
+ self.sock.sendall(IAC + WONT + opt)
elif c in (WILL, WONT):
opt = self.rawq_getchar()
self.msg('IAC %s %d',
if self.option_callback:
self.option_callback(self.sock, c, opt)
else:
- self.sock.send(IAC + DONT + opt)
+ self.sock.sendall(IAC + DONT + opt)
else:
self.msg('IAC %d not recognized' % ord(opt))
except EOFError: # raised by self.rawq_getchar()