ok ill start off with a little background. I work for a company which makes heavy duty wireless routers/bridges, which work over long distances. Up to 30miles. Now each of our units comes with a scan utility, which can be used to default and change the ip of units. A quick example, say your on a network of 192.168.100.0. You obviously wont be able to comminicate with our unit on your network if the units ip is 206.71.186.46. The scan utility uses broadcasts to let recieve info about the unit and let you change a few things so that you will be able to connect to it. I hope thats clear enough.
Now, im working on a linux version of the client side scan utility. Now what this does is bind a udp socket to each network card installed on the computer. It then procedes to send broadcast probes out each socket.
My problem is in the thread which waits to recieve a probe response from our units when they recieve a broadcast. Im using select() to wait for a response on one of those sockets and then respond. Ive used a packet capture program to capture the packets, so I know that the probe goes out, and the unit sends the appropriate response back to the computer. So the select call should show that their is information waiting on whichever socket it came in on. However it times out instead. About 3/4 of the time this works fine. Heres the code for the problem area. -
FD_ZERO(&readSet);
-
NumOfSockets = maxSocket = 0;
-
for(int i=0; i<6; i++) // get all valid sockets from socket array
-
{ // and add them to select call
-
if(socketDescriptor[i] != 0x0)
-
{
-
FD_SET(socketDescriptor[i], &readSet);
-
NumOfSockets++;
-
if(maxSocket<socketDescriptor[i])
-
{
-
maxSocket = socketDescriptor[i];
-
}
-
}
-
}
-
time.tv_sec = 1;
-
time.tv_usec = 0;
-
// wait up to 1 second for a response from the unit
- active = select(maxSocket+1, &readSet, NULL, NULL, &time);
-
if (active > 0)
-
{
-
UnitDetected=1;
-
for(int i=0; i<6; i++)
-
{
-
if(socketDescriptor[i]==0)//added to handle a bug which occured if the first nic didnt have a unit attached
-
{
-
continue;
-
}
-
else if (FD_ISSET(socketDescriptor[i], &readSet))
-
{
-
UnitDetected=1; // if a unit responds, turn this flag on
-
if (recv(socketDescriptor[i], buf, MAX_LINE, 0) < 0)
-
{
-
perror("Recv info: ");
-
continue;
-
}
-
test = (A_UINT16 *)buf;
-
if(ntohs(*test)==PROBE_RESPONSE_MSG)
-
{
-
// does stuff, when probe is recieved.
-
}
-
else if(ntohs(*test)==COMMAND_RESPONSE_MSG)
-
{
-
// does stuff when a command response is recieved
-
}
-
else
-
{
-
cout << "Invalid unit response" << endl;
-
ProbeRDY = 0; //set flag off
-
CmdRDY = 0; //set flag off
-
}
-
}
-
}
-
else if (active == 0)
-
{
-
cerr << "Select call timed out . . ." << endl;
-
ProbeRDY = 0;
-
CmdRDY = 0;
-
}
-
else
-
{
-
perror("select: ");
-
UnitDetected = 0;
-
ProbeRDY = 0;
-
CmdRDY = 0;
-
}
-
}
Sorry for the length! I tried to shorten it as much as possible. Any idea's or possible work arounds would be helpfull, thanks!
2 3870
i added some code to double check that each socket is actually timing out, in the part that handles timeouts in the above code. So far that seems like its solved the problem, but i havent had time to really test it yet. It seems to me like the select call has a few problems. I might just write my own select method to simplify things if it is a problem with select()
Hi Ashaman0,
does select parameter 'readSet' in your sample contains the data it receives from the socket? Am a bit confuse about this function. I really need help.
Thanks
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: pbbriggs |
last post by:
I will try to be as descriptive as possible, but this error has me
stumped and I am not sure what relevant info to include....
I am running Access XP on a Windows XP machine. I initially began
developing an app in Access 2000 but converted it several months ago
to XP. So the app is now Access XP format also.
My app is crashing on a regular basis, with the totally non-descript
Microsoft error (Microsoft Access has encountered a...
|
by: Terencetrent |
last post by:
I having been using Access '97/2002 for about 4 years now and have
never really had the need or the time to learn visual basic. Well, I
think the time has finally come.
I need help with Visual Basic code that will examine numeric value for
a particular field in a query, and assign a new numeric vaule to that
field. There are over 21 possible values and I am told that IIF
statement will only handle 9 of the possibilities and that I need...
|
by: David |
last post by:
I am using ADO to run some SQL statements in Access.
First, I run query to create a table using SELECT . . . INTO Table A.
Then, I run a query to SELECT . . . FROM Table A to get some data and
the table is empty.
This appears to be a timing issue because the second query works when
I run it in ACCESS instead of in VB following the first statement.
|
by: Brian |
last post by:
Hello all -
I am trying to Insert a new record to an Access 2002 database.
Following the insert, I need to obtain the primary key of the inserted
row (person_ID) which is an Autonumber field. I am using the
following code (obtained from MSDN) to do this, but for some reason a
value of 0 is returned. Why is 0 returned????
Dim newID As Integer = 0
|
by: C.Joseph Drayton |
last post by:
I have a problem that I am hoping someone can help me with.
First let me describe the problem. I have an HTML form that in one
field has an onBlur call to a JavaScript function. When you exit the
field, it calls the JavaScript routine, which in turn calls a PHP
script. The PHP script runs returns the value needed. And returns to
the JavaScript. The JavaScript function is then supposed to set
alerts depending on the values returned from...
| |
by: Ian Richardson |
last post by:
Hi,
The function I've put together below is a rough idea to extend a SELECT
list, starting from:
<body>
<form name="bambam">
<select id="fred">
<option value="1">1</option>
<option value="2">2</option>
|
by: Ron Garret |
last post by:
Here's my code. It's a teeny weeny little HTTP server. (I'm not really
trying to reinvent the wheel here. What I'm really doing is writing a
dispatching proxy server, but this is the shortest way to illustrate the
problem I'm having):
from SocketServer import *
from socket import *
from select import select
class myHandler(StreamRequestHandler):
|
by: Richard Cranium |
last post by:
Hello,
I have an interesting problem:
I've got one thread in my program meant to maintain a timing subsystem
and to do network I/O. It uses the select() system call to either wait
for I/O or "time out" and "handle" some arbitrary "event".
The timeout value for select() is calculated off of a list of "active
timers" which contains all the necessary information to correctly guess
|
by: BD |
last post by:
Hi, all.
My background is more Oracle than db2. My skills at SQL tuning are
quite limited.
I'm running 8.2 on Windows.
I'm tasked with some SQL optimization, and am doing some explain plans
on various queries.
|
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...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |