Linux-Development-Apps Digest #584, Volume #6 Fri, 5 May 00 15:13:14 EDT Contents: Why Quicktime???? ([EMAIL PROTECTED]) Re: [Q] Writing TCP server. (Eric P. McCoy) Re: Wait for multiple objects ? (Kaz Kylheku) [Q] logging and LOG_LOCALx (Robert J. Sprawls) Re: SOCK_RAW and low level Ethernet Frames ("netghost") Re: Wait for multiple objects ? ("Hubert") Linking errors on RedHat 6.1 (Martin Brown) Re: C++ lib files (FT3/AB Ulm") optimizer & pgcc (Leander Seige) Re: Linux console termcap and line drawing errors ("T.E.Dickey") GTK linux-windows ("charlesd") WANTED libg++-XXX (=?iso-8859-1?Q?Beno=EEt?= Smith) How to call kernel module's functions (Ivan Martinez) Need to find my IP address (Doug Schulz) Re: Need to find my IP address ("Jerry Williams Jr.") Re: How to call kernel module's functions (Kaz Kylheku) ---------------------------------------------------------------------------- From: [EMAIL PROTECTED] Subject: Why Quicktime???? Date: Fri, 05 May 2000 03:11:04 GMT Ok, I know I can't view quicktime files (at least the good ones i.e. movie trailers). But the question is why is quicktime the popular format? What happened to mpeg, avi, etc.? Thanks, (Kinda pissed, I wanta view MI2 and others with win95). Tom Sent via Deja.com http://www.deja.com/ Before you buy. ------------------------------ Subject: Re: [Q] Writing TCP server. From: [EMAIL PROTECTED] (Eric P. McCoy) Date: 04 May 2000 23:20:25 -0400 [EMAIL PROTECTED] writes: > 1. How can I stop the server that handles incoming clients very quickly > from overloading the system? Don't accept() connections faster than a certain rate. Use gettimeofday() for a reasonable-precision timer. init(8) does something like this. It won't allow a process to be restarted more than a certain number of times in a certain number of minutes, or it disables respawning for a while. You should consider something similar for your server. Depending on your situation, it may be best to let connections pile up in the listen() backlog, close them immediately, or whatever. > 2. Aside from this, my server prints the port the client is connecting > from when it recieves a connection. It takes the client port from the > structure passed to accept(). When I run the tester program, I noticed > that the port number, starting from around 1200, is incremented by one > each time... I don't understand why it's incrementing, or changing at > all. My programs use port 4000, so shouldn't it always output 4000? The value you get from accept() is the *client* port number. A TCP connection is between two ports on two IPs. You can see this with netstat(8): tcp 0 128 cs.hamilton.edu:telnet apathos.hamilton.edu:2250 Recall that TCP is a connection-based protocol. It requires a port on both ends. The port assigned for an outgoing connection is probably determined by what's free. Linux probably just increments the port number each time so it doesn't have to check through the entire portlist again, until you've used all the ports there are. (At which point it increments until 1024, which will probably be free, and starts again.) -- Eric McCoy ([EMAIL PROTECTED]) "And what happens? The guy goes and proves himself beyond all doubt to be just another cookie stamped out of the Dough of Idiocy with the Cookie-Cutter of Self-Righteousness." - Mike Kozlowski ------------------------------ From: [EMAIL PROTECTED] (Kaz Kylheku) Subject: Re: Wait for multiple objects ? Reply-To: [EMAIL PROTECTED] Date: Fri, 05 May 2000 07:30:30 GMT On Fri, 5 May 2000 08:47:29 +0200, Hubert <[EMAIL PROTECTED]> wrote: > >"Kaz Kylheku" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED]... >| On Wed, 3 May 2000 09:07:09 +0200, Hubert <[EMAIL PROTECTED]> wrote: >| >Hi, >| > >| >I try to port some code from windows to linux. In that code I use alot of >| >events and WaitForMultipleObjects(). >| > >| >Is it possible for a program running on linux to wait for multiple >objects >| >like it is possible for windows programs? >| >| Wait for *what* multiple objects? Since there are no events on Linux, >| this question is meaningless. > >Yes I know that there are no such things like events on linux. I think >that's a real pity. I don't. I think that events are almost completely retarded. (Except that auto-reset events are actually binary semaphores in disguise so they are okay.) We could do without race condition bugtraps like PulseEvent in Linux, for sure. Oh yeah, and what about the idiotic limit of 64 handles into WaitForMultipleObjects? If you are going to provide a multiple wait function, you should do it like you mean it! >| WaitForMultipleObjects is a brain-damaged, unnecessary hack that is >fraught >| with potential pifalls such as starvation > >Not every thing on Windows is bad ;-). I think the extensive possibilities >of event handling on windows is really missing on linux. There is no synchronization task in Win32 that you can't do with mutexes and condition variables. If you want event-like objects with a multiple wait function, that can be done too. >Exactely, I use them for thread synchronisation. For example each thread has >a private event and a public event. If the private event becomes signaled, >this means that there is a job for the thread to do. If the public event >becomes signaled, it means that all threads should stop execution and exit >gracefully. >So I put the "exit" event in the low order of the array, because it has >higher priority. You don't always need this under POSIX because there is a standard way to request thread cancellation. You say pthread_cancel() and the thread will be unblocked from its condition variable wait, and will execute clean-up handlers and go away. In Win32, you can only TerminateThread which is crude and dangerous, with no resource cleanup. In any case, an active object can simply support a shutdown method which does whatever it takes to deactivate its thread(s): for example, set a shutdown flag to true and unblock the thread from whatever it is doing. There thread merely needs one mutex to protect its shared data and one condition variable. The thread's shutdown function simply locks the mutex, sets the shutdown variable to true, unlocks and signals the condition. Whenever the thread wakes up and acquires the mutex, it checks the shutdown flag. So the thread is still waiting for one of two *reasons* to wake: work to do, or shutdown. -- #exclude <windows.h> ------------------------------ From: [EMAIL PROTECTED] (Robert J. Sprawls) Subject: [Q] logging and LOG_LOCALx Reply-To: [EMAIL PROTECTED] Date: Fri, 05 May 2000 07:16:39 GMT What is the use of LOG_LOCALx? Are these reserved by the system? Robert ------------------------------ From: "netghost" <[EMAIL PROTECTED]> Subject: Re: SOCK_RAW and low level Ethernet Frames Date: Fri, 5 May 2000 14:55:20 +0800 Reply-To: "netghost" <[EMAIL PROTECTED]> I am also working on that topic on the rawpackets sending programming under unix... As far as I know: SOCK_RAW is not enough to emplement the raw packet sending,you need to use PF_PACKET or AF_PACKET in socket function... I am studying on that now,but not quite clear myself... If you are interesting ,please contact it with me... "Mark" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > Hi, > I'm currently working on a program which creates an Ethernet Frame > from scratch and transmits (sendto()) it out onto the LAN. I've got a > couple of problems with it. > > 1) When it gets up to around 1500 Frames Per Second (146Bytes per frame > on 10Mbps LAN i.e around 10% utilisation) the are a load of collisions, > and I'm not sure what causing them. The sendto() doesn't report any > errors. I know (At slow speeds) the frames are correctly formed as I've > checked them with a LAN analyser. > > 2) This is possibly related to (1) as it's something which I thought I > might be causing the problem. Currently in the socket() function I'm > using SOCK_PACKET. Which according to the man pages is obsolete and > should be replaced with SOCK_RAW. However it's not a direct replacement. > I've looked though the man pages and on the net, but haven't found out > what changes I have to make to get SOCK_RAW to work (I assume it's what > I need). Does anyone know what these differences are, or where I can > find out. > > Many thanks for any help > > Mark > ------------------------------ From: "Hubert" <[EMAIL PROTECTED]> Subject: Re: Wait for multiple objects ? Date: Fri, 5 May 2000 08:47:29 +0200 "Kaz Kylheku" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... | On Wed, 3 May 2000 09:07:09 +0200, Hubert <[EMAIL PROTECTED]> wrote: | >Hi, | > | >I try to port some code from windows to linux. In that code I use alot of | >events and WaitForMultipleObjects(). | > | >Is it possible for a program running on linux to wait for multiple objects | >like it is possible for windows programs? | | Wait for *what* multiple objects? Since there are no events on Linux, | this question is meaningless. Yes I know that there are no such things like events on linux. I think that's a real pity. I | | Linux has the select and poll functions in order to *fairly* multiplex input | and output on multiple file descriptors. For file I/O this is ok, but for thread synchronisation it's a hack. | | WaitForMultipleObjects is a brain-damaged, unnecessary hack that is fraught | with potential pifalls such as starvation Not every thing on Windows is bad ;-). I think the extensive possibilities of event handling on windows is really missing on linux. If you handle it right, it's a great help. But it is like a sharp knife, I you don't know how to handle it, you get hurt. | |(if more than object is signalled, it | reports the one that has the lowest position in the array). Yes, but this is a good feature. You order the events in the array by your own priority. If several events become signaled, WaitForSingleObject() returns with the event, which you gave the highest priority. Of course all the other events remaind signaled if you said "manual reset". You catch them with the next call to WaitForMultipleObjects(). | | I suspect that your code uses events in order to communicate among objects. | This kind of design usually gives rise to the need for WaitForMultipleObject. | For example suppose you design a module which allows the caller to register | an event via which the caller will be notified. As soon as one client | wants to use two such modules, it needs to be able to wait for either event | and so WaitForMultipleObjects sneaks into the code. Exactely, I use them for thread synchronisation. For example each thread has a private event and a public event. If the private event becomes signaled, this means that there is a job for the thread to do. If the public event becomes signaled, it means that all threads should stop execution and exit gracefully. So I put the "exit" event in the low order of the array, because it has higher priority. | | If you use side effects on operating-system specific objects in order to glue | your program's modules together, you get a portability hassle. Thats my problem :-( | | In C and C++, the means of communicating notifications among modules is the | function call. If you need independent notification from two or more modules, | just have them call you. The call can wake up a thread that is waiting on just | one internal semaphore or condition variable. The synchronization details are | buried in the implementation of the object where they belong rather than in the | interface. | | -- | #exclude <windows.h> Why not? But before excluding it, move some of the goodies over to linux ;-) Hubert ------------------------------ From: Martin Brown <[EMAIL PROTECTED]> Subject: Linking errors on RedHat 6.1 Date: Fri, 05 May 2000 10:55:45 +0100 Hi, I am trying to link against a commercial library and I get the following link errors: /usr/lib/libxxxx.so: undefined reference to `_xstat' /usr/lib/libxxxx.so: undefined reference to `__setjmp' The glibc FAQ tells me that this is because the library should not be calling functions that start with an underscore, thus they are not available external to libc. (nm tells me they are in there) However, since this is a commercial library and the support is not great, I can't do anything about this. Is there any way of getting this thing to link? ldd -v gives me: statically linked Version information: /lib/libNoVersion.so.1: libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libc.so.6: ld-linux.so.2 (GLIBC_2.1.1) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2 I am running libc.so.6 -> libc-2.1.2.so Thanks Martin ------------------------------ From: "Christoph Wiedemann (FT3/AB Ulm)" Subject: Re: C++ lib files Date: Fri, 05 May 2000 12:01:49 +0200 Reply-To: [EMAIL PROTECTED] "D. Stimits" wrote: > > "D. Stimits" wrote: > > > > Hi: > > > > I'm trying to find out more about creating dynamically loadable > > library files, for later use with dlopen(). Basically, I find that the > > usual procedure for C lib files doesn't complain, even though g++ is > > used starting on cpp files with classes, templates, so forth. E.G.: > > g++ -c -fPIC something.cpp -o something.o > > g++ -c -fPIC other.cpp -o other.o > > g++ -shared -Wl, -soname, libwhatever.so.1-o libwhatever.so.1.0 > > something.o other.o > > > > This doesn't seem to be complete though. What are the extra steps to > > create something like this where I can access classe implementations > > through dlopen()? > > > > Eventually my goal is to create a C++ lib that links with C++ > > programs, and a C wrapper lib that uses extern "C"...so the C program > > can eventually migrate to the C++ version. > > > > Thanks! > > D. Stimits > > -- > > [EMAIL PROTECTED] > > I managed to get some information about this, stating the goal is > possible (thanks to Eric Youngdale). One of the main problems I was > made aware of is automatic name mangling of symbols. I'm still > interested in more details on the above, but would like to add the > topic of egcs' internal name mangling. Can anyone tell me if any > functions are available to help me predict a mangled name (so I can > dlopen() the mangled name directly), or to read a lib's mangled > symbols and decrypt it to unmangled? > > Thanks, > D. Stimits > > -- > [EMAIL PROTECTED] There is also a function which works in one direction called c++filt. I couldn't find any info pages on my system, but as an example, the command "c++filt createApresLoaderMono__FPCcP8DefaultsP16InspectorHandler" yields createApresLoaderMono(char const *, Defaults *, InspectorHandler *). I'm also interested in a function which does this vice versa. Thanks, Christoph Wiedemann ------------------------------ From: Leander Seige <[EMAIL PROTECTED]> Subject: optimizer & pgcc Date: Fri, 05 May 2000 13:00:17 +0100 Reply-To: [EMAIL PROTECTED] hallo everyone, i'm writing a very small program but it must be as fast as possible. at this time, i have a binary generated by the pgcc and this one is very fast but i want to try to improve it even more. i found the program 'optimizer', which provides PII optimizations. but it doesnt work with the .s files from gcc or pgcc, it quits with a parse error. does anybody know this program, is it better than the pgcc or how does it work right? thank you, Leander ------------------------------ From: "T.E.Dickey" <[EMAIL PROTECTED]> Subject: Re: Linux console termcap and line drawing errors Crossposted-To: comp.databases.informix Date: Fri, 05 May 2000 15:18:55 GMT In comp.os.linux.development.apps John Hardin <[EMAIL PROTECTED]> wrote: > John Hardin wrote: >> >> Several curses applications compiled under Linux (most notably menuing >> programs) don't draw line graphics properly - if the application >> attempts to display a line of text, followed by whitespace (tabs & >> spaces), followed by a line drawing character, the tabs and spaces are >> drawn in the alternate character set. > Oops. It turns out that the application was at fault. It was switching > to graphics mode *before* moving the cursor, and was moving the cursor > by displaying spaces instead of using a cursor-addressing escape > sequence. then it probably wasn't an ncurses app (ncurses checks that) -- Thomas E. Dickey [EMAIL PROTECTED] http://www.clark.net/pub/dickey ------------------------------ From: "charlesd" <[EMAIL PROTECTED]> Subject: GTK linux-windows Date: Fri, 5 May 2000 11:34:30 -0400 I am thinking of writing an application but I would like it to be available in both Windows and Linux. If I use the GTK how easy is it to port my Linux app over to wIndows. I am just talking about the GUI part. ------------------------------ From: =?iso-8859-1?Q?Beno=EEt?= Smith <[EMAIL PROTECTED]> Subject: WANTED libg++-XXX Date: Fri, 05 May 2000 20:11:14 +0200 Greetings, All my feeblest apologies if this question sounds stupid to you, but I am a Linux close-to-newbie. I recently downloaded GCC 2.95.2, but when I looked into the contents of the tarball, I didn't find any directory related to the libg++-??? libraries. Could I have missed something, or do I really have to seek those libs elsewhere ? BTW, are the latest libg++-??? libs compliant with the 2.7.2 version ? Any answer would be appreciated. Thanks in advance. Benoît Smith ------------------------------ From: Ivan Martinez <[EMAIL PROTECTED]> Subject: How to call kernel module's functions Date: Fri, 05 May 2000 22:41:33 +0200 Reply-To: [EMAIL PROTECTED] Hello all, I know how to program and install a kernel module, but I don't know how to call its functions from user space. Also I don't know if such functions should be declared in a special way in the module. Could anybody point me to documentation about that, or give me an example, or explain it?. (Answers like "you have to use the calling interface." won't help). Many thanks. -- Ivan Martinez (Rodriguez) BEng in Software Engineering - MEng student http://www.student.dtu.dk/~u990873 "Got fabes?" ------------------------------ Crossposted-To: comp.os.linux.development.system,comp.os.linux,comp.os.linux.misc Date: Fri, 5 May 2000 11:46:48 -0700 From: Doug Schulz <[EMAIL PROTECTED]> Subject: Need to find my IP address I have a sockets program an need to find the IP address of the machine the program is being run from so I can bind the socket to the correct address/port. I have tried using gethostname coupled with gethostbyname and I can only get 127.0.0.1 (localhost address). I want to find the actual IP address of the machine. Is there a way of doing this. Any help would be great. FYI this is a UDP app. Thanks, Doug ------------------------------ From: "Jerry Williams Jr." <[EMAIL PROTECTED]> Crossposted-To: comp.os.linux.development.system,comp.os.linux,comp.os.linux.misc Subject: Re: Need to find my IP address Date: Fri, 05 May 2000 18:55:32 GMT Doug Schulz wrote: > > I have a sockets program an need to find the IP address of the machine > the program is being run from so I can bind the socket to the correct > address/port. I have tried using gethostname coupled with gethostbyname > and I can only get 127.0.0.1 (localhost address). I want to find the > actual IP address of the machine. Is there a way of doing this. Any > help would be great. > > FYI this is a UDP app. > > Thanks, > > Doug ifconfig Jerry ------------------------------ From: [EMAIL PROTECTED] (Kaz Kylheku) Subject: Re: How to call kernel module's functions Reply-To: [EMAIL PROTECTED] Date: Fri, 05 May 2000 19:00:42 GMT On Fri, 05 May 2000 22:41:33 +0200, Ivan Martinez <[EMAIL PROTECTED]> wrote: > Hello all, > I know how to program and install a kernel module, but I don't know how >to call its functions from user space. Also I don't know if such The short answer is that you can't. The long answer is that your driver can register itself with the kernel and provide an ioctl() function which can support custom operations specific to your device. In user space you can write a tiny library of wrappers around ioctl() calls. The user gets in touch with your driver (for example) by opening a special entry in the filesystem created with mknod which refers to your driver by major number. In the case of a network driver, it can do so by creating a socket and binding to your network driver by name. In any case, somehow the application creates a file descriptor which is bound to your driver. It can then execute your special ioctl's on it, naked or through the convenience library. ------------------------------ ** 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 (and comp.os.linux.development.apps) via: Internet: [EMAIL PROTECTED] 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 ******************************