While I could gather, both the open system called generated by the DB and
the socket() syscall are returning a FD=3.
That is, they are both trying to use the same filedescriptor. My guess is
packets get sent to that file descriptor, instead of the port. How can I
changed this? I just followed standar procedure to allocate a socket:
sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP))

Shouldn't the Kernel take care of this and provide an unused FD??

On Wed, Mar 24, 2010 at 11:57 AM, Martin Sigwald <msigw...@gmail.com> wrote:

> I tried using STRACE, unfortunately, I am quite new to Linux programming,
> so I can't make much sense out of the output. I attached it to this email,
> in case some kind soul would like to take a look at it.
> The program ran is exactly this:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sqlite3.h>
> #include "ping.h"
>
> int main(void){
>     sqlite3* db_handle=NULL;
>
>     ping_pong("10.0.0.3",2); //IP number + timeout in seconds --> This
> pings works fine
>
> if(sqlite3_open("guido.db",&db_handle))
>         {
>             fprintf(stderr,"Error while opening
> DB:%s\n",sqlite3_errmsg(db_handle));
>             exit(1);
>         }
>  if(sqlite3_close(db_handle))
>         {
>             fprintf(stderr,"Error while closing
> DB:%s\n",sqlite3_errmsg(db_handle));
>             exit(1);
>         }
>     ping_pong("10.0.0.3",2); // This ping doesnt work
>     return 0;
>
> }
>
> On Wed, Mar 24, 2010 at 4:51 AM, Roger Binns <rog...@rogerbinns.com>wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Martin Sigwald wrote:
>> > Here is the actual code:
>> >
>> > int main(void)
>> > {
>> >     sqlite3* db_handle;
>> >
>> >      sqlite3_open(DB_NAME,&db_handle);
>> >      sqlite3_close(db_handle);
>> >      my_ping("10.0.0.4");
>> >
>> >       return 0;
>> > }
>> >
>> > If I call close after ping, it works. However, if besides of opening the
>> DB
>> > I perform any query, ping doesnt work either.
>>
>> My best guess is that you are making an error with file descriptors.  It
>> can be quite easy to accidentally use various values with low numbers
>> instead of the actual file descriptor numbers, and you'll get away with
>> it until some other code (eg sqlite) opens and closes files.  (Note that
>> under some circumstances SQLite can leave file descriptors open even
>> after close is called.)
>>
>> I suggest using strace and carefully examining the file descriptors used.
>>
>> Roger
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAkupxGUACgkQmOOfHg372QTd2ACeNaCEFII4TuVK8ZtTpCvZeFeX
>> ivYAnjuLh8uKl1z1jVauy9Fxa60Po9RR
>> =AVyR
>> -----END PGP SIGNATURE-----
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to