TypeError: an integer is required (got type bytes) error correction method of seeking correction

tags: python  TypeError: an integer is required (  socket.send()

TypeError: an integer is required (got type bytes) error correction method of seeking correction

Traceback (most recent call last): File “F:/python/automatic/tsTserv.py”, line 18, in tcpCliSock.send(time,data)

TypeError: an integer is required (got type bytes)

import socket
import time
HOST = ''
PORT = 21568
BUFSIZ = 1024
ADDR = (HOST,PORT)
tcpSerSock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
tcpSerSock.bind(ADDR)
tcpSerSock.listen(5)
while True:
    print('waiting for connection')
    tcpCliSock,addr = tcpSerSock.accept()
    print('...connected form:',addr,tcpCliSock)
    while True:
        data = tcpCliSock.recv(BUFSIZ)
        if not data:
            break
        **tcpCliSock.send(bytes(time.ctime(), encoding='utf-8'),data)**
    tcpCliSock.close()
tcpSerSock.close()

Intelligent Recommendation

Python: Use PyInstaller to package into an exe file, and TypeError: an integer is required (got type bytes) exception resolution

Using Python 3.6 or above to use pyinstaller for packaging will result in a TypeError: an integer is required (got type bytes) exception. The solution and installation pyinstaller tutorial are as foll...

Python3.8 uses scikit-learn0.20.2 Times Wrong Typeerror: an Integer is Required (got type bytes)

I must record this problem, because I have gone too much road, spend too much time! Problem Description: When the brother's project is placed on his computer, no module name 'error appears, after seve...

When importing the Sklearn library, encounter TypeError: an integer is required (got type bytes)

When importing the Sklearn library, encounter TypeError: an integer is required (got type bytes) First check your Sklearn version, when you install Sklearn, if you use the following PIP command, you m...

TypeError: an integer is required (got type str)? Solution

Code: An error was encountered when opening files The following code changes to solve the problem The specific reasons unknown, seeking answers to big brother...

More Recommendation

【Python】TypeError: an integer is required (got type str)

Problems encountered in debugging code today TypeError: an integer is required (got type str) problem causes In the open function of the open file object in python3, the following is the wrong way of ...

TypeError: an integer is required (got type str)

This is type alone What is needed is an int type, but input is a STR type  ...

TypeError: an integer is required (got type is tuple)

TypeError: an integer is required (got type is tuple), This error. To understand it literally, you need to obtain a integer data, and the original code is the tuple. What needs to be done is to change...

[Solve Pycharm remotely running server connection error problems] Typerror: An Integer is Required (GOT TYPE BYTES)

.pycharm_helpers/third_party/thriftpy/_shaded_thriftpy/_compat.py  Use the following code to replace the original file code...

pyspark: Typerror: An Integer is Required (GOT TYPE BYTES) solution

This machine environment: spark2.4.4, MINICONDA's latest Python 3.9 Run bin/pyspark Times wrong as follows: When it is said on the Internet, Spark is not so friendly for the latest Python version. It ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top