Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How to make the program connect to next IP address without exiting program, if the current connection fail??

Reply
Thread Tools

How to make the program connect to next IP address without exiting program, if the current connection fail??

 
 
Abby
Guest
Posts: n/a
 
      08-28-2003
I'm writing a code to send/receive udp packet. I'll receive ip address
from user (this is the starting ip), then I'll ask user how many ip he
wants to connect to. For examples:

Please enter 1st ip: 192.168.0.1
How many ip do you want to connect to: 10

Then, my program will create an array to store 10 ip addresses,
starting from
192.168.0.1
....
....
192.168.0.10

Then, I'll use each ip to open socket, send udp packet to each ip in
order. Below is the general idea of what my program does to send and
receive packet.

struct resp_pkt * pkt;
char ip[node][16]; // ip array used to store multiple ip address

for (i=0;i<node;i++){
sockfd = open_socket(ip[i]);
pkt = action(sockfd, udp_pkt);
if(!pkt) {
printf("Connection fail\n");
close(sockfd);
}
close(sockfd);
}

*** My problem is that if it fail to receive udp packet from any ip
address, the program will exit, and will not go on to the next ip. How
can I force it to just send out message and go on to the next ip?? ***

Right now, when it can't connect to the next ip, it will show error
message "Connection fail", then exit the program. Anybody has an idea
how to achieve this? Thank you so much!!!
 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      08-29-2003
On 28 Aug 2003 16:53:17 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (Abby) wrote in
comp.lang.c:

> I'm writing a code to send/receive udp packet. I'll receive ip address
> from user (this is the starting ip), then I'll ask user how many ip he
> wants to connect to. For examples:


[snip]

You need to ask this in a support newsgroup for your particular
compiler/operating system combination to see what sort of networking
features it provides. C has no built-in support for any sort of
networking at all, so it's off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Problem in exiting from a file and continue with next file Karthi kn Ruby 2 04-10-2008 01:44 PM
Runtime.getRuntime.exec() without exiting the main program knguyen Java 9 02-15-2008 07:33 PM
PythonWin: any way to delete all objects without exiting and without doing it with "del"? dananrg@yahoo.com Python 5 03-03-2006 05:12 PM
CurrentElement->next = CurrentElement->next->next (UNDEFINED?) Deniz Bahar C Programming 2 03-09-2005 12:45 AM



Advertisments