473,320 Members | 1,867 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,320 software developers and data experts.

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

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!!!
Nov 13 '05 #1
1 2810
On 28 Aug 2003 16:53:17 -0700, ab*****@yahoo.com (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
Nov 13 '05 #2

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

Similar topics

11
by: anuradha.k.r | last post by:
hi, i am writing a socket program in python,both client side and server side.I've written the client side which is working perfectly fine(checked it against server program written in C).but as for...
1
by: OZ | last post by:
the serproxy claim itself a multi-thread proxy thing. I have sent email to write the original writer and there is no replay after 3 weeks. my configuration and setting are good. ...
14
by: Henk | last post by:
Hi Guys, (see actual code below) I wrote a little program that is supposed to read a file (input.txt) into memory (using a stack) and then reverse the file and display it to output. It works,...
2
by: Chris Lane | last post by:
Hi, I am using the following connection string format in an ASP.NET 1.1 application to attempt to connect to a SQL Server on another machine. Data Source=ServerName;Initial Catalog=DBName;User...
7
by: Ralf Gedrat | last post by:
Hello! I have some Vb.Net applications, which are terminated at indefinite times without message. If I call in the program regulated system.GC.Collect, then the program is terminated here...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
43
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
12
by: =?Utf-8?B?S2plbGw=?= | last post by:
Hello I've taken a four days training in C#, very good training, experienced teacher and all that, very positive. Went home spent a week making my first application, slightly more than the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.