473,230 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

how to fill many data strings from socket.recvfrom()

I want to receive 200 udp datagrams. Each into a new data string.
But I dont know how to do that, this is wrong:

import socket
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(("",port))
i = 0
while i<200:
data[i],addr = s.recvfrom(1024)
i = +1

data[i] is illegal.

Any suggestion welcome!

Nov 3 '07 #1
2 3127
data[i] is illegal.
Any suggestion welcome!
Either initialize data before: data=[0]*200 before "while" or
(better):
....
i=0
data=[]
for i in range(200):
d,addr= s.recvfrom(1024)
data.append(d)
Nov 3 '07 #2

"lgwe" <la*******@gmail.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...
>I want to receive 200 udp datagrams. Each into a new data string.
But I dont know how to do that, this is wrong:

import socket
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(("",port))
i = 0
while i<200:
data[i],addr = s.recvfrom(1024)
i = +1

data[i] is illegal.

Any suggestion welcome!
import socket
s=socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(('',5000))
data=[]
for i in range(200):
tmp,addr = s.recvfrom(1024)
data.append(tmp)

-Mark
Nov 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gordon Wetzstein | last post by:
Hello everyone, I have a problem with python sockets. I broadcast a lot of pickled objects with socket. sendto(...), that works. Ireceive them on the other site with socket.recvfrom(16384) The...
8
by: simon place | last post by:
Spent some very frustrating hours recoding to find a way of closing a server socket, i'd not thought it would be any problem, however, after complete failure and as a last resort, i looked at the...
5
by: Terry | last post by:
It's my understanding of UDP sockets that if there is a thread blocked on a "recvFrom()" call and other thread sends a UDP packet to some address, that if the machine on the other end isn't up,...
2
by: Vitali Gontsharuk | last post by:
Hi! I have a problem programming a simple client-server game, which is called pingpong ;-) The final program will first be started as a server (nr. 2) and then as a client. The client then...
1
by: Jack | last post by:
Hi guys, I can't figure this out. rec = recvfrom(sdUDP, buf, BUFSIZE, 0, (struct sockaddr *)&connectChannel, &chanSizeUDP ); while(1){ if (rec 0){ snt = sendto(sdUDP, buf, rec, 0, (struct...
6
Sagittarius
by: Sagittarius | last post by:
I will first try to describe my problem in words. I have a simple program, written in C++, that needs to send a single bytearray via a UDP socket to a microprocessor, which returns an answer, also...
4
by: gaddamreddy | last post by:
Hai to all frns, Reqirement 1: 1.I need to send a Request to one server through UDP socket.at that time i have to start a timer (setted to 2 sec) if i wont get the Response/ACK from that...
3
Sagittarius
by: Sagittarius | last post by:
Hi there. I have a problem concerning an UDP socket in C++ (Winsock). The next paragraphs is merely to explain the system I am working on. If U want to skip it, I have marked the question in...
0
by: bndifek | last post by:
Hi I have a problem with raw socket. I want send SYN packet but I have a problem with checksum. When I send the packet to second komputer I see it in ethereal on the second computer( on the close...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.