473,661 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(s ocket.AF_INET,s ocket.SOCK_DGRA M)
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 3151
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*******@gmai l.comwrote in message
news:11******** **************@ o80g2000hse.goo glegroups.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(s ocket.AF_INET,s ocket.SOCK_DGRA M)
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
3809
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 pickled objects are smaller (like 10000 bytes) than the max bytes. The problem appears if I send too many pickled objects very quickly one after another, then I only receive a part of the sent objects.
8
9276
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 python wrapper module for sockets, and found that the close command doesn't actually call the underlying close! this didn't seem right, so i added it, and my code now works simply and as expected. def close(self):
5
11683
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, that the "recvFrom()" call should just continue blocking. Right? What I'm seeing is that when I send a packet to a particular address that is not responding, my "recvFrom()" call throws an exception. I get "An existing connection was forcibly...
2
5180
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 sends the message "Ping" to the server, which reads it and answers with a "Pong". The game is really simple and the coding should be also very simple! But for me it isn't. By the way, the program uses datagram sockets (UDP). And, I'm using
1
6005
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 sockaddr *)&connectChannel, chanSizeUDP ); rec = recvfrom(sdUDP, buf, BUFSIZE, 0, (struct sockaddr
6
15772
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 via UDP. Everything works just fine - exept when packet loss occurs (or nothing is recieved at the recieving socket). If packet loss occurs, the program locks up, and it needs to be restarted! Here comes the question:
4
5112
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 corresponding ACK from that server within 2 sec.i need to send the Request again. for this i did like this. #include <sys/types.h> #include <sys/socket.h>
3
3650
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 bold below it. I have a pc, connected to a network of boards, all connected in a ring, all having their own unique IP adresses. As it is now, I send messages to the network of boards via broadcast, so all the boards gets the message. All the...
0
2074
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 port), but it shows that the packet has Incorect checksum. And the second komputer don't send packet to my kmoputer ( I have no reply ACK).I build RAW SOCKET like bellow: #include <netdb.h> #include <netinet/ip.h> #include <netinet/tcp.h>...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8542
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.