473,516 Members | 3,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UDP data transfer hangs on recvfrom

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
*)&connectChannel, &chanSizeUDP );
}
else{
stats();
exit(0);
}
}

The above is the code from a UDP server. The server is suppose to
simply read the incoming data from the buffer and echo it back to the
client. For some reason the code hangs on the recvfrom inside the
while loop. I don't know why this happens... The client sends and
receives the data but the server never exits.

Any ideas..

Feb 1 '07 #1
1 5993
Jack schrieb:
Hi guys,
I can't figure this out.
[...socket stuff...]
The above is the code from a UDP server. The server is suppose to
simply read the incoming data from the buffer and echo it back to the
client. For some reason the code hangs on the recvfrom inside the
while loop. I don't know why this happens... The client sends and
receives the data but the server never exits.
Read here:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Feb 1 '07 #2

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

Similar topics

2
3261
by: William | last post by:
I have declared the following struct: struct PropagateInfo { string type; // "registration", "gossip", "termination" int initiatePeerID; }; which I used as follows: PropagateInfo* initiatePeerInfo = new PropagateInfo; initiatePeerInfo->type = type; // type is set to "registration"
2
20735
by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none But the problem occures when i want to send a data with & sign (i.e: Firm=F&B). I try to solve this problem with using boundary, but i failed. Any...
2
2062
by: D.Frangiskatos | last post by:
Hi, I have been working for a few months in project that deals raw sockets. However recently, and while trying to examine the contents of the buffer used in recvfrom i was a bit confused. The buffer was allocated using malloc as it can be seen next: do { ..............
9
8445
by: Omega | last post by:
I have a problem with recvfrom(). I get a message and no error occurs, but the struct sockaddr* from is not filled with sender's data. The client's source code: #include "reversi.h" ------------------------------------------------------------------- int main() { int socket_id = socket(PF_INET,SOCK_DGRAM,0); struct sockaddr_in adres;
0
1140
by: Michael Bacarella | last post by:
Hi list, I'm 99% sure httplib is sporadically hanging when I call read() on the HTTPResponse object (r.status == 200). Evidence: straceing the process shows it's blocked in recvfrom() ls -la /proc/pid/fd shows the socket-id for recvfrom() file descriptor (3) lsof -n | grep socket-id shows the connection to the HTTP server (on
2
3140
by: lgwe | last post by:
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,addr = s.recvfrom(1024) i = +1
0
1220
by: Jeff | last post by:
Hi, Fairly new to python, messing with some socket and pcap sniffing and have come across the following issue while trying to do a pcap_loop (via pcapy http://oss.coresecurity.com/projects/pcapy.html). I believe i recall seeing similar stuff using other pcap libs with python in the past (such as pylibpcap) in a nutshell, blocking on a...
3
6093
by: jkvbe | last post by:
Hi, I get a "Bad address" error message when trying to receive an ICMP timestamp packet using recvfrom in cygwin. The packet is OK as I see it arriving when sniffing the network. Any ideas what can be wrong? Thanks,
2
5595
by: kardon33 | last post by:
Is there a difference between the way the function recvfrom and sendto use the address structure. When i use sento it works fine, but when I try and use recvfrom with the same variables it errors out with (bad address). Or is there a better way to receive packets from a socket that i just sent to. Theres some of my source code. ...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7405
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. ...
0
7574
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...
1
7136
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...
0
5712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
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...
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
487
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...

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.