473,394 Members | 1,703 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,394 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 3133
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.