小编Tom*_*mmy的帖子

使用Android NDK的SQLite

是否有可能在Android手机上使用SQLite和C++?我没有找到任何关于如何实现这一目标的文件.

c++ java-native-interface android android-ndk

22
推荐指数
2
解决办法
2万
查看次数

使用Python通过TCP传输文件

我目前正在开发一个python项目,需要通过Python套接字从客户端传输到服务器.这是我当前的代码,但是不传输整个文件,但根据文件大小,总会丢失一些或者额外的字节.

_con和con是通过python套接字的连接包装器连接.

客户:

def _sendFile(self, path):
    sendfile = open(path, 'rb')
    data = sendfile.read()

    self._con.sendall(data)

    self._con.send(bytes('FIN', 'utf8'))
    # Get Acknowledgement
    self._con.recv(6)

def _recieveFile(self, path):
    # Recieve the file from the client
    writefile = open(path, 'wb')
    i = 0
    while (1):
        rec = self.con.recv(1024)
        if (rec.endswith(b'FIN')):
            break
        writefile.write(rec)

    self.con.send(b'ACK')
Run Code Online (Sandbox Code Playgroud)

python tcp

3
推荐指数
1
解决办法
4283
查看次数

标签 统计

android ×1

android-ndk ×1

c++ ×1

java-native-interface ×1

python ×1

tcp ×1