Linux-Development-Apps Digest #376, Volume #7     Thu, 3 May 01 06:13:05 EDT

Contents:
  network deamon ("boaz")
  ftok : Will it always be unique? ("Michael Zowacki")
  Re: User <--> Kernel Space (Pete Zaitcev)
  Transfer data to mySQL Server
  Re: ftok : Will it always be unique? ("Bill Medland")
  Re: Transfer data to mySQL Server ([EMAIL PROTECTED])
  Re: ftok : Will it always be unique? (Eric P. McCoy)
  Re: Transfer data to mySQL Server (Dean Thompson)
  read/write of socket, threading ("D. Stimits")
  Re: Transfer data to mySQL Server ("D. Stimits")
  Simple task_struct question (Frank)
  Simple task_struct question (Frank)
  Re: Transfer data to mySQL Server
  Re: Transfer data to mySQL Server (Dean Thompson)
  Re: Transfer data to mySQL Server
  Re: Transfer data to mySQL Server (Dean Thompson)
  Re: Transfer data to mySQL Server ("D. Stimits")
  GCC-Timeout handling on a serial device, hanging in read ("Eberhard Wagner")
  Multi-thread programming in C/C++ ("cui bin")
  close() trouble with sockets ("Aleksi Asikainen")

----------------------------------------------------------------------------

From: "boaz" <[EMAIL PROTECTED]>
Subject: network deamon
Date: Wed, 2 May 2001 14:20:31 -0700

Just how do I call/use the services from the Network Deamon in Linux?


--
-



------------------------------

From: "Michael Zowacki" <[EMAIL PROTECTED]>
Subject: ftok : Will it always be unique?
Date: Wed, 02 May 2001 22:18:01 GMT

I was reading the documentation and it said that ftok may not return a
unique key.  This is quite disturbing since for the application that i'm
designing I 'MUST' garuentee a unique key.  Is this in fact true and if so
is there anyway to generate a unique key?  I just can't see anyone writing a
function to return a unique value that may not always work.  I also realize
that this would be a statistical game on actually recieving an already used
key,  however even though the odd's may be extremely slim for this
application I'd rather be safe.   Thanks all!



------------------------------

From: Pete Zaitcev <[EMAIL PROTECTED]>
Subject: Re: User <--> Kernel Space
Date: Wed, 02 May 2001 15:31:49 -0700

>     ssize_t cp380_write (struct file *filp, const char *buf, size_t count,
> loff_t *lof)
>     {
>          int data;
> 
>          printk ("\n\nCP380 : Writing in progress ...");
> 
>          get_user (data,buf);
>          printk ("\nCP380 : The integer is : %d",data);
> 
> // The result is : The integer is : 0     !!!!!!!!!!
> 

Of course. get_user picks the type from the second argument.
Best of all is never use get_user and use copy_from_user instead.

-- Pete

------------------------------

From: <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Transfer data to mySQL Server
Date: Thu, 3 May 2001 00:43:01 +0200

Hi,
what possibilities exist to transfer few data to a mySQL Database running on
a Linux Red Hat Server 7.0? Have I to implement my own server program in C++
or any other programming language or are there any less complicated solution
for this kind of problem?

Thanks a lot in advance




------------------------------

From: "Bill Medland" <[EMAIL PROTECTED]>
Subject: Re: ftok : Will it always be unique?
Date: 02 May 2001 23:08:43 GMT

I met this one a couple of weeks ago too.  Here's my input.

Wall's "Linux Programming by example" contains the warning, basically
quoting straight from the man page.

Matthew & Stones' "Beginning Linux Programming" doesn't even mention ftok;
it uses a static value for the SysV IPC ids.

It seems to me that what the man page is saying is that the algorithm being
used is a function based on file system properties (basically a hash of the
filename) which contains quite a good chance of being reasonably unique and
having similar property to posix IPC (being based on filenames).

Of course any hash function based on the filesystem is going to have little
chance of uniqueness when combined with "user-generated values".

It seems to me that the unix-style approach would be to use a configuration
setting of some sort to allow the administrator to specify the key value,
with some sort of sensible default.  Alternatively you can use IPC_PRIVATE
but it is still unclear to me whether e.g. shared memory allocated with
IPC_PRIVATE is or is not supposed to be accessible from other processes.

Bill

------------------------------

From: [EMAIL PROTECTED]
Subject: Re: Transfer data to mySQL Server
Crossposted-To: comp.os.linux.development.system,comp.database 
Date: Wed, 02 May 2001 23:19:16 GMT

<[EMAIL PROTECTED]> writes:
> what possibilities exist to transfer few data to a mySQL Database
> running on a Linux Red Hat Server 7.0? Have I to implement my own
> server program in C++ or any other programming language or are there
> any less complicated solution for this kind of problem?

First comment: This question does not need to have _anything_ to do
with Red Hat, or, for that matter, Linux.  MySQL runs as happily atop
all sorts of Linux "user spaces," as well as various BSDs and Unixes,
so that answers need have _nothing_ to do with anything systematically
oriented towards Linux.

As a result, I've directed followups to comp.database, likely a more
appropriate destination.

You've got a wide variety of options, as MySQL provides bindings to
quite a number of languages.  It is accessible from C, C++, as well as
just about any scripting language, as they can inherit APIs from C.

If you've got a one time transfer of data into a MySQL database, then
you could use just about any tool that would transform that data into
a set of SQL "INSERT" statements.

If I had a small set of such data, I might very well pull it into Gnu
Emacs, switch on "macro recording," transform one line into an INSERT
statement, and then take the resulting macro and run it on the rest of
the lines.

I did this once to load about 40,000 stock prices into a PostgreSQL
database.  It was slow enough that I regretted _not_ writing a program
to parse the text file.

The next simplest choice would be to write a script in some language
like Perl, Python, REXX, or Lisp that would take the input file and
produce a whole bunch of INSERT statements.

More sophisticated would be to write a script in a scripting language
that supports direct interfacing to MySQL.  Perl and Python are both
good examples of this; you can open a connection to the database, and
then pump in INSERTs.

The _LAST_ choice I'd suggest would be to write a program in C/C++.
It's certainly feasible, and is likely able to be faster than any of
the others.  But if it's a one shot operation, the extra time spent
developing it is not likely to be worthwhile.  And the "faster" part
may turn out to be statistical noise.  If it takes an extra 8 hours to
develop something that drops a one time data load from 25 minutes to
20 minutes, that seems to me to likely be a sheer _waste_ of 7 hours
and 55 minutes.

If your data is coming in as xBase data, I believe that there is a
utility specially written to help load that sort of thing into MySQL.
-- 
(concatenate 'string "cbbrowne" "@acm.org")
http://vip.hex.net/~cbbrowne/resume.html
"I develop for  Linux for a living, I used to  develop for DOS.  Going
from DOS to Linux is like trading a glider for an F117."
-- <[EMAIL PROTECTED]> Lawrence Foard

------------------------------

Subject: Re: ftok : Will it always be unique?
From: [EMAIL PROTECTED] (Eric P. McCoy)
Date: 02 May 2001 20:31:48 -0400

"Michael Zowacki" <[EMAIL PROTECTED]> writes:

> I was reading the documentation and it said that ftok may not return a
> unique key.  This is quite disturbing since for the application that i'm
> designing I 'MUST' garuentee a unique key.  Is this in fact true and if so
> is there anyway to generate a unique key?  

The man page for ftok() explains when it won't be unique.  You can
duplicate the function call yourself (it seems straightforward) and
ignore the parts that may cause duplication.

> I just can't see anyone writing a function to return a unique value
> that may not always work.

Well, what do you expect?  Given an arbitrary input of arbitrary
length that has to be collapsed to a finite integer, you're naturally
going to get duplicates.

> I also realize that this would be a statistical game on actually
> recieving an already used key, however even though the odd's may be
> extremely slim for this application I'd rather be safe.  Thanks all!

Make a list of the keys you're issued and check for duplicates.  Use
mutexes or whatever to prevent overlapping.  Then figure something out
for cases where there _are_ duplicates.

-- 
Eric McCoy <[EMAIL PROTECTED]>
  "Knowing that a lot of people across the world with Geocities sites
absolutely despise me is about the only thing that can add a positive
spin to this situation."  - Something Awful, 1/11/2001

------------------------------

From: Dean Thompson <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server
Date: Thu, 03 May 2001 11:59:03 +1000


Hi!,

> what possibilities exist to transfer few data to a mySQL Database running 
> on a Linux Red Hat Server 7.0? Have I to implement my own server program in 
> C++ or any other programming language or are there any less complicated 
> solution for this kind of problem?

Depending on the SQL language that MySQL is using, you should be able to use
some standard SQL queries to import text via a properly formatted txt file.  I
think from memory, the INSERT sql command can take a file, although it has
been awhile since I have used SQL.

See ya

Dean Thompson

-- 
+____________________________+____________________________________________+
| Dean Thompson              | E-mail  - [EMAIL PROTECTED] |
| Bach. Computing (Hons)     | ICQ     - 45191180                         |
| PhD Student                | Office  - <Off-Campus>                     |
| School Comp.Sci & Soft.Eng | Phone   - +61 3 9903 2787 (Gen. Office)    |
| MONASH (Caulfield Campus)  | Fax     - +61 3 9903 1077                  |
| Melbourne, Australia       |                                            |
+----------------------------+--------------------------------------------+

------------------------------

Date: Wed, 02 May 2001 21:45:30 -0600
From: "D. Stimits" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: read/write of socket, threading

I'm wondering if it is possible for a single socket to have one thread
writing in a loop, and simultaneously a second thread reading (TCP/IP
socket connection). If read and write, or send and recv are used, but
only one thread does sending (only one sender at a time) and only one
thread does receive (only one receiver at a time), will this be a point
of failure? I haven't found any reference on whether a single socket's
send and receive streams are bound together in a way that would
interfere with this.

D. Stimits, [EMAIL PROTECTED]

------------------------------

Date: Wed, 02 May 2001 21:52:29 -0600
From: "D. Stimits" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server

[EMAIL PROTECTED] wrote:
> 
> Hi,
> what possibilities exist to transfer few data to a mySQL Database running on
> a Linux Red Hat Server 7.0? Have I to implement my own server program in C++
> or any other programming language or are there any less complicated solution
> for this kind of problem?
> 
> Thanks a lot in advance

One really big question is "what format is your current data in"?

D. Stimits, [EMAIL PROTECTED]

------------------------------

From: Frank <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Simple task_struct question
Date: Wed, 02 May 2001 21:41:29 -0700

Hi,

I was just wondering.  What must I include in my code in order to get a
pointer to the task_struct 'current'?

Frank
TIA

------------------------------

From: Frank <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Simple task_struct question
Date: Wed, 02 May 2001 21:41:29 -0700

Hi,

I was just wondering.  What must I include in my code in order to get a
pointer to the task_struct 'current'?

Frank
TIA

------------------------------

From: <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server
Date: Thu, 3 May 2001 09:49:04 +0200

Hi,
>
>One really big question is "what format is your current data in"?
It could be ASCII or any other format, because i develope also the program
in win32 which will send the data to the linux red hat server.

Bye
Julia





------------------------------

From: Dean Thompson <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server
Date: Thu, 03 May 2001 17:52:54 +1000


Hi Julia,

> >One really big question is "what format is your current data in"?
> It could be ASCII or any other format, because i develope also the program
> in win32 which will send the data to the linux red hat server.

You shouldn't have a problem then importing your data via a text file which is
delimited by commas for instance.  Check out the "insert" command under SQL
and see whether or not it provides support for importing text files. 
Additionally, you might like to check out the URL:
http://www.itlab.musc.edu/mysql_import/readme.html which is an application
written to allow you to import data into your MySQL database via a web
interface.  Could it be any easier :)

You might like to check that out as being another method of getting data into
your database.

See ya

Dean Thompson

-- 
+____________________________+____________________________________________+
| Dean Thompson              | E-mail  - [EMAIL PROTECTED] |
| Bach. Computing (Hons)     | ICQ     - 45191180                         |
| PhD Student                | Office  - <Off-Campus>                     |
| School Comp.Sci & Soft.Eng | Phone   - +61 3 9903 2787 (Gen. Office)    |
| MONASH (Caulfield Campus)  | Fax     - +61 3 9903 1077                  |
| Melbourne, Australia       |                                            |
+----------------------------+--------------------------------------------+

------------------------------

From: <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server
Date: Thu, 3 May 2001 09:58:05 +0200


Hi,

>> >One really big question is "what format is your current data in"?
>> It could be ASCII or any other format, because i develope also the
program
>> in win32 which will send the data to the linux red hat server.
>
>You shouldn't have a problem then importing your data via a text file which
is
>delimited by commas for instance.  Check out the "insert" command under SQL
>and see whether or not it provides support for importing text files.
And how does mySQL know to open the text file and read the data in? Have i
there to specify a directory, where it will check for new files every minute
or something like that?

Thanks in advance
Julia




------------------------------

From: Dean Thompson <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server
Date: Thu, 03 May 2001 18:11:31 +1000


Hi Julia,

>>> >One really big question is "what format is your current data in"?
>>> It could be ASCII or any other format, because i develope also the
>>> program in win32 which will send the data to the linux red hat server.
>>
>>You shouldn't have a problem then importing your data via a text file which
>>is delimited by commas for instance.  Check out the "insert" command under 
>>SQL and see whether or not it provides support for importing text files.

> And how does mySQL know to open the text file and read the data in? Have i
> there to specify a directory, where it will check for new files every 
> minute or something like that?

The insert command takes the file from the current directory that you are in. 
However, I am getting this feeling that you are developing an application
which is purely using the DBMS as a data store while allowing a client program
to maniuplate the data.

If that is the case, then you will want to look at the MySQL manual and
interface with the database over its TCP/IP port.

See ya

Dean Thompson

-- 
+____________________________+____________________________________________+
| Dean Thompson              | E-mail  - [EMAIL PROTECTED] |
| Bach. Computing (Hons)     | ICQ     - 45191180                         |
| PhD Student                | Office  - <Off-Campus>                     |
| School Comp.Sci & Soft.Eng | Phone   - +61 3 9903 2787 (Gen. Office)    |
| MONASH (Caulfield Campus)  | Fax     - +61 3 9903 1077                  |
| Melbourne, Australia       |                                            |
+----------------------------+--------------------------------------------+

------------------------------

Date: Thu, 03 May 2001 02:16:18 -0600
From: "D. Stimits" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Crossposted-To: comp.os.linux.development.system,comp.os.linux.networking
Subject: Re: Transfer data to mySQL Server

[EMAIL PROTECTED] wrote:
> 
> Hi,
> 
> >> >One really big question is "what format is your current data in"?
> >> It could be ASCII or any other format, because i develope also the
> program
> >> in win32 which will send the data to the linux red hat server.
> >
> >You shouldn't have a problem then importing your data via a text file which
> is
> >delimited by commas for instance.  Check out the "insert" command under SQL
> >and see whether or not it provides support for importing text files.
> And how does mySQL know to open the text file and read the data in? Have i
> there to specify a directory, where it will check for new files every minute
> or something like that?
> 
> Thanks in advance
> Julia

If the text data is delimited in a way that is friendly for MySQL, it
can be fairly easy. Tab delimited (and I think comma) are trivial. The
key is the "LOAD" command. One sample reference book I have shows this:
LOAD DATA [LOCAL] INFILE file [REPLACE|IGNORE]
   INTO TABLE table [delimiters] [(columns)]

Simply using "LOAD DATA INFILE" will assume tab delimited. Other options
include: "FIELDS TERMINATED BY 'c'", "FIELDS ENCLOSED BY 'c'", "FIELDS
ESCAPED BY 'c'",  "LINES TERMINATED BY 'c'".

To use that you simply connect via something like:
mysql --user=julia --host=localhost -p

Then give it the pass.

C++ apps to read files as import are not particularly hard; compared to
some of the VC++ MFC stuff it is quite easy. Now something that seems
very useful here for you in particular is TkExpect. TkExpect is used to
automate command line functions basically by observing it and giving
responses. You might want to check that out for some more automated
means of doing this once you are able to do it by hand.

D. Stimits, [EMAIL PROTECTED]

------------------------------

From: "Eberhard Wagner" <[EMAIL PROTECTED]>
Subject: GCC-Timeout handling on a serial device, hanging in read
Date: Thu, 3 May 2001 11:23:54 +0200

I have problems with a timeout handling of a serial device . There is
everything ok, if the device ís answering. But if the device is not
answering the program should go out of the "read" - instruction for further
action.
The code below is used in AIX, there the code works properly, not in Linux
Does anyone know a solution ?
Eberhard


Linux SuSe 7.1
====================
...
...
signal(SIGALRM,(void(*)()) sk_timeout);
alarm(1);
ios = read (chan,buffer,len);
alarm(0);
signal(SIGALRM, SIG_DFL);
...
...
=================
void sk_timeout()
{
signal(SIGALRM, SIG_DFL);
}



------------------------------

Date: Thu, 3 May 2001 17:18:14 +0800 
From: "cui bin" <[EMAIL PROTECTED]>
Subject: Multi-thread programming in C/C++

Hi, all,
       Does anyone have code samples about Multi-thread programming in
C/C++? If have, please send a copy to me or tell me the website.

thanks a lot

cuibin



------------------------------

From: "Aleksi Asikainen" <[EMAIL PROTECTED]>
Subject: close() trouble with sockets
Date: Thu, 3 May 2001 13:14:27 +0300

I'm running a small server on Red Hat Linux 7.0 / Kernel 2.2.16-22smp (2x
i686).

It's using sockets in non blocking mode, with SO_KEEPALIVE set to 1, and
SO_LINGER set to l_onoff=1, l_linger=0.

What happens, is that the server blocks in a close(socket) call sometimes.
It calls close, and doesn't return from it, it's blocking in there for some
reason.

If one runs gdb, you find that it's in the system call for close(). And if
you detach the program and let it keep running, since you knocked it out of
that blocking close call, it proceeds normally and runs fine again for a
while.

There's no breakpoints set, the program seems to stop randomly on that close
call.

What am I doing wrong?


I used to run this little server on Solaris-86 (2.6), and it ran smoothly
with no problems.



Aleksi Asikainen



------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.apps newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-Apps Digest
******************************

Reply via email to