diff --git a/src/lua/bsdsocket.lua b/src/lua/bsdsocket.lua
index c42b5657f9b10c49e44461d69fb82576bd8e3fe2..797220e80fe83aaf30c6ca55fc016a1d74e7cd52 100644
--- a/src/lua/bsdsocket.lua
+++ b/src/lua/bsdsocket.lua
@@ -684,6 +684,7 @@ socket_methods.write = function(self, octets, timeout)
         timeout = TIMEOUT_INFINITY
     end
 
+    local total_len = #octets
     local started = box.time()
     while timeout > 0 and self:writable(timeout) do
         timeout = timeout - ( box.time() - started )
@@ -691,12 +692,12 @@ socket_methods.write = function(self, octets, timeout)
         local written = self:syswrite(octets)
         if written == nil then
             if not errno_is_transient[self:errno()] then
-                return false
+                return nil
             end
         end
 
         if written == string.len(octets) then
-            return true
+            return total_len
         end
         if written > 0 then
             octets = string.sub(octets, written + 1)
@@ -710,11 +711,11 @@ socket_methods.send = function(self, octets, flags)
 
     self._errno = nil
     local res = ffi.C.send(fd, octets, string.len(octets), iflags)
-    if res == -1 then
+    if res < 0 then
         self._errno = box.errno()
-        return false
+        return nil
     end
-    return true
+    return tonumber(res)
 end
 
 socket_methods.recv = function(self, size, flags)
@@ -782,9 +783,9 @@ socket_methods.sendto = function(self, host, port, octets, flags)
     end
     if res < 0 then
         self._errno = box.errno()
-        return false
+        return nil
     end
-    return true
+    return tonumber(res)
 end
 
 local function create_socket(domain, stype, proto)
diff --git a/test/box/bsdsocket.result b/test/box/bsdsocket.result
index d3ad14f9aa68c65d8a4a37b584860b0032624160..6e32dc74f344577663d77a1a4d86adaa7b30b3ea 100644
--- a/test/box/bsdsocket.result
+++ b/test/box/bsdsocket.result
@@ -304,7 +304,7 @@ lua sc:writable(10)
 ...
 lua sc:write('Hello, world')
 ---
- - true
+ - 12
 ...
 lua sa, addr = s:accept()
 ---
@@ -338,7 +338,7 @@ lua sc:writable()
 ...
 lua sc:write(', again')
 ---
- - true
+ - 7
 ...
 lua sa:read(8)
 ---
@@ -366,7 +366,7 @@ lua sc:writable()
 ...
 lua sc:send('abc')
 ---
- - true
+ - 3
 ...
 lua sa:read(3)
 ---
@@ -374,7 +374,7 @@ lua sa:read(3)
 ...
 lua sc:send('Hello')
 ---
- - true
+ - 5
 ...
 lua sa:readable()
 ---
@@ -390,15 +390,15 @@ lua sa:recv()
 ...
 lua sc:send('Hello')
 ---
- - true
+ - 5
 ...
 lua sc:send(', world')
 ---
- - true
+ - 7
 ...
 lua sc:send("\nnew line")
 ---
- - true
+ - 9
 ...
 lua sa:read('\n', 1)
 ---
@@ -419,7 +419,7 @@ lua sa:read('ine', 0.1)
 ...
 lua sc:send('Hello, world')
 ---
- - true
+ - 12
 ...
 lua sa:read(',', 1)
 ---
@@ -508,7 +508,7 @@ lua sa:nonblock(true)
 ...
 lua sa:send('Hello, world')
 ---
- - true
+ - 12
 ...
 lua sc:recv()
 ---
@@ -614,7 +614,7 @@ lua sc = box.socket('AF_INET', 'SOCK_DGRAM', 'udp')
 ...
 lua sc:sendto('127.0.0.1', 3548, 'Hello, world')
 ---
- - true
+ - 12
 ...
 lua s:readable(10)
 ---
@@ -626,7 +626,7 @@ lua s:recv(4096)
 ...
 lua sc:sendto('127.0.0.1', 3548, 'Hello, world, 2')
 ---
- - true
+ - 15
 ...
 lua s:readable(10)
 ---
@@ -673,7 +673,7 @@ lua sc:sendto('127.0.0.1', s:name().port)
 ...
 lua sc:sendto('127.0.0.1', s:name().port, 'Hello, World!')
 ---
- - true
+ - 13
 ...
 lua s:readable(1)
 ---
@@ -688,7 +688,7 @@ lua data
 ...
 lua s:sendto(from.host, from.port, 'Hello, hello!')
 ---
- - true
+ - 13
 ...
 lua sc:readable(1)
 ---
@@ -731,7 +731,7 @@ lua string.match(tostring(s), ', peer') ~= nil
 ...
 lua s:write('HEAD / HTTP/1.0\r\nHost: tarantool.org\r\n\r\n')
 ---
- - true
+ - 40
 ...
 lua header = s:read({chunk = 4000, line = { '\n\n', '\r\n\r\n' }}, 1)
 ---
@@ -1106,7 +1106,7 @@ lua cnt
 ...
 lua client:write('hi')
 ---
- - true
+ - 2
 ...
 lua client:read(123)
 ---