how to send a large array over tcp socket in python? is it possible to send? [closed]
2024/11/24 8:06:00
I don't have an example to show. I referred some online site, but didn't find anything that met my requirement. Please anyone give me an example to use.
Answer
There are multiple options. I would try:
instead of large array, try to get a generator or iterator which would provide items one by one. This could save you memory in sending process (but is is not necessary, if you can live with whole array in memory)
do not use plain sockets, use ZeroMQ (which runs on top of it).
define a protocol for sending the array. Assuming the array is flat, it can go with following types of messages:
startarray
itemdata
endarray
loop over items to send and send them as one by one, before sending "startarray" message, then one item by one, finally closing by "endarray" message
for transfer over TCP, you need to pick some serializatio format. I would start with JSON.
sender could use ZMQ socket of type PUSH, receiver would be using PULL.
Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 5…
This question already has answers here:How do I Pandas group-by to get sum?(11 answers)Closed 1 year ago.Ive had a good hunt for some time and cant find a solution so asking here.
I have data like so:…
values = [2,3,4]
for v in values:values.append([v,255,255])Why do the statements above never end? I make a mistake in my code. However, I find it will never stop when I execute the code above.
Can we resize an image from 64x64 to 256x256 without affecting the resolution is that a way to add zero on new row and column in the new resized output I m working on vgg and I get an error while addin…
This question already has answers here:How slicing in Python works(38 answers)Closed 6 years ago.OK I understand the basics, but can someone explain code copied from Gregs answer here:a[1::-1] # the …
This question already has an answer here:How to compare characters of strings that are elements of a list? [duplicate](1 answer)Closed 2 years ago.Having a Python list, containing same length strings,…
Spark version 3.0.
I have two dataframes.
I create one dataframe with date columns using pandas date range.
I have a 2nd spark dataframe contains the company name, dates and value.
I want to merge the …
I am a beginner programmer. Here is my code:n = int(input())
from math import*
for i in range(n):print(n, "\t", log10(n))i = i + 1n = n - 1Its output is:10 1.0
9 0.9542425094393249
8 …
This question already has answers here:Closed 12 years ago.Possible Duplicate:
How do I use method overloading in Python?I am new to Python programming, and I like to write multiple methods with the …
I have a food menu and the stock and prices are in separate dictionaries.Food Stock:Food_Stock = {Chips : 15,Bagels : 27,Cookies : 25}#Food Stock.Food Prices:Food_Prices = {#Food Prices.Chips : 1,Bagel…