473,765 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Connect ion 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 2833
On 28 Aug 2003 16:53:17 -0700, ab*****@yahoo.c om (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.l earn.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
8525
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 my server program written in python it simply hangs.it does not show any error also.I've tried sample programs available .I don understand what the reason is as i am quite new to it. here is teh server side program: ///////////////////////
1
2472
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. http://www.lspace.nildram.co.uk/freeware.html I installed it in rh 9.0 I found it is single user only.
14
1853
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, but I still get some errors when i try to compile it: stack.c: In function 'reverseFile'
2
2408
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 ID=username;password=pwd;persist security info=True; I am testing this asp.net app. from my local IIS to connect to a SQL Server instance on another box. It will not work and I am unable to determine why, I
7
6711
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 sporadically without message. It's not possible to debug in visual studio, i get no exceptions (application is terminated unexpectedly without message).
6
4900
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
14
7042
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 sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
43
3433
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
1899
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 usual "Hello world". Took it with me to my best customer, and beleive it or not....It will not work !!!!
0
10160
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
10007
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
9951
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,...
1
7378
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
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
5275
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...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
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.