Programming :: How To Detect Compressible Data
Apr 13, 2011
I am working on a project that takes multiple blocks of memory that are no more than 1500 bytes in side and tries to compress them. Currently I just compress them and compare the old length to the new length. If the new length is smaller it copies the compressed data into the original datas memory space.The problem I have is when lots of these blocks of memory do not compress well its huge amounts of wasted CPU.
View 6 Replies
ADVERTISEMENT
Sep 23, 2009
i wanted to capture the stdout and stdin of a child process within a parent so that any output of child is sent to the parent and any input taken from the parent. code is simple enough and i have followed all code guidlines on the internet (some guidlines do differ also) my select call either hangs if i do not give a tmeout and with a timeout it returns 0 descriptors to be written to or read from:
below is the simple code for parent:
int main(void)
{
int outfd[2];
int infd[2];
[code].....
why select hangs without a timeout ... why can it not detect that the pipe is write ready i.e parent can write to it ... if it does not detect tha read pipe as having data...
View 5 Replies
View Related
Mar 9, 2011
I am writing a TCP server in C, and the server listens to incoming client connections and accepts them. It then creates a thread to handle the client. The clients are expected to only receive data from my server and not send any data. So if I use a select() call with a recv(), I believe that the recv() will just block forever since there will not be any data coming from the client. If I use a non-blocking recv(), then this will just return a 0 which tells me nothing because the client is not expected to send any data. I am not sure if I have misunderstood some socket concepts, but I need a solution to detect when the client has disconnected so that I can close the socket and stop sending data to the client. As I understand it, simple ACKs etc are not captured by the recv(), and only data sent by the client will cause recv() to return a non-zero value, so I am not sure how to know when the client has disconnected.
View 7 Replies
View Related
Jun 11, 2009
I am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:
//------------------------------------------------------------
char m_readBuffer[255] = {0};
char* p_curChar = m_readBuffer;
[code]...
View 1 Replies
View Related
May 9, 2010
I have some data files that should be distributed with my program. Using dist_pkgdata_DATA in Makefile.am, I get these files installed to /usr/local/data/share/package-name. The problem is that data is read-only, and my program needs to modify it. Playing with dist_sharedstate_DATA, dist_localstate_DATA, dist-data_DATA varibles, I got different installation directories, like /usr/local/com, usr/local/var, but data is always read-only.
How can I distribute modifiable data files with my package? I need some common directory for all users, or maybe local data in a user directory.
View 1 Replies
View Related
Mar 4, 2011
I am trying to generic way to convert the string datatype to other primitive data type. To achieve, i used Template . But i getting error and couldn't resolve the issue and error reported is also clueless.
Code
====
#include <vector>
#include <iostream>
#include <string>
[Code].....
View 7 Replies
View Related
Oct 8, 2010
I have been trying to code a program in C++ that must check for the correct syntax in order to operate. It must find ", " within the string, but I don't know why the compiler won't recognizes spaces.
Code:
#include <iostream>
#include <stdio.h>
#include <string>
[Code]....
So the user must input "<name>, <interest>" with the ", " (comma and space) but even if you respect the syntax the compiler will skip to the else condition. I don't know why, but if I put any other condition like ",s" it will work, but not with spaces.
View 7 Replies
View Related
Mar 8, 2011
iam just trying to connect to server which accepts one client and server will read(blocking operation) infinitely, but After closing the client socket the server "read operation" is returning zero and "errno variable(in errno.h)" value is also zero. how can i detect whether a client socket is closed/active..?
client.c
Serv_Addr.sin_family = AF_INET;
Serv_Addr.sin_addr.s_addr = inet_addr("127.0.0.1");
Serv_Addr.sin_port = htons(26553);
if( 0 > connect (Serv_Fds,&Serv_Addr,sizeof(Serv_Addr)) )
{
perror("connect");
return 0;
[Code]....
View 3 Replies
View Related
Apr 14, 2011
I have to read files from a linux server. When I copy a file I receivce just a portion of the file I expected if the process generationg ths file is still writing it.
I read the file from a java apllication using SSH/SFTP. How can I detect if the file is still used by the writing process ?
View 4 Replies
View Related
Dec 8, 2010
Code:
#if defined(WIN32) || defined(WIN64)
#define WINDOWS
#endif
[code]....
what is the directive thats required to detect a linux system? i want to to be able to detect which platform im compiling on automatically.
View 5 Replies
View Related
Oct 21, 2010
I'm witting a piece of code that needs to read key presses. However I cannot use them as stream, but rather need discrete reads. The code is to simulate an io board interface. So When I press say "d" I need to read it in instantly, not wait for return. I've tried sdl, but no luck (I'm reading in a thread and it causes some problems) I'm using linux so can't use conio.h functions, I've tired gatch from cureses but this still waits for return.So in C/c++ is there a way I can read instant key presses.
View 1 Replies
View Related
Jan 24, 2009
I'm looking for a way to detect whether or not a program has been called from pipe, e.g.
Code:
whatever | my_program
versus simply just being exectuated directly:
Code:
my_program
Why? In the first case, I want to run the program non-interactively, and in the latter case I want to print out user-friendly messages. I've been thinking along the lines of some check I haven't yet found, like:
Code:
if( stream_buffer_is_not_empty() )
print_interactive_messages();
View 1 Replies
View Related
Jun 28, 2010
Detect the current window that has the focus. For example at the moment am using firefox therefore teh function should say firefox is the main window.
View 2 Replies
View Related
Jun 3, 2011
I have a question today: "How to detect client use Sock or Proxy?"Note: I hope everyone serious discussion.
View 1 Replies
View Related
Jul 19, 2011
how to detect if a file is being opened by any application so that i can block it just before opening it... Actually i am working on android and using iNotify in JNI to detect the OPENING of a file...but the file is getting opened before the iNotify detects it..and therefore its displaying the contents of the file unmodified .. The actual requirement is that if anyone is trying to open the file it should be modified by my program and then the modified file should be opened.
View 10 Replies
View Related
Jun 24, 2010
I am working on debian based OS and my query is,how to make detect the Number of NIC's plugged on a PC.
I describe it: Exact requirement would, assume, If I plug 3 NIC's for a PC,one for Internal Network,one for External Network and Other remaining one for DMZ,so I need to make an application(Firewall Kind)in such a way that,once my PC is started,it should detect how many NIC's are plugged and Whats their role played(As Mentioned above)..?
I hope u guys got a basic idea on what and how it it can be implemented..
I request to send some clues,or some related URL's/Tutorials or which part of the Linux File System needs to be edited(/etc or/proc),etc.
View 2 Replies
View Related
May 15, 2011
I tried, of course:
Code:
awk '/^./ {print}' FILE.TXT
That does not work, I just get an empty output, even if FILE.TXT contains lines which fit the desired regexp I've searched but did not found my way. I'd like to do it with awk, as I want my program to rely only on awk, nothing else such as sed, grep, etc.
View 12 Replies
View Related
Apr 4, 2011
I need a good way to detect if a box is solaris or linux and then be able to run out a os-centric command given the output...
View 7 Replies
View Related
Oct 4, 2010
Is possible to detect port scanning just by using utilities included in linux (netstat, iptables...), Yes there is utility called psad but I would write some scripts for my own and learn something new
writing own Intrusion Detection System? I am not a C++ geeg, so first thing that comes to my mind is that i will use simple BASH SCRIPT that will interact with iptables and monitor user activity, network activity etc. (but I thing that would not be good solution due to performance and capabilities, and also I am not familliar with memory in linux at all). I was reading aboud SNORT HIDS, NIDS... AFAIK some information can be obtainet from /proc but I have no idea which values should be monitored.
View 1 Replies
View Related
Oct 27, 2010
Is any way to detect a keypress event in a console session? Preferebly without needing the application to be running in the foreground
View 2 Replies
View Related
May 21, 2011
Using xsel I pass a selection into a variable. I then check that the variable includes an embedded newline to be sure that the selection returned by xsel is complete. If the selection content preceding the newline is just a single word, the check fails to detect the newline, thus
Code:
g fnm=`xsel`
g cat <<< "$fnm"
Whatis
apropos sear
[code]....
View 14 Replies
View Related
Dec 28, 2010
In C++ or C, is there anyway to detect the name of the module or driver currently used by a network interface card (either wired or wireless, INCLUDING USB DEVICES)?My application must have this feature. I just want to detect whether the module / driver is ndiswrapper or not.
View 4 Replies
View Related
Aug 6, 2010
Reading some examples on net and copying some codes I was able to build a (frankstein) server that accept connection from one client and receive and send messages to it. The big problem that shows up is that I don't know when client disconnects from my server.
I've been looking for a solution, but no success. I'd read about SO_KEEPALIVE option (which could solve my problem), but I don't know how to use it (how to check the value of it).
I can't use ping because the server (machine) could be running, but not the client (software).
Anyone knows a good tutorial or how to (for beginners like me xD) of TcpIp sockets using c/c++ and how to detect when a client disconnect?
I don't know sockets very well.
View 6 Replies
View Related
Mar 11, 2009
write a C program to detect whether the Ethernet cable is plugged or unplugged. I found out by using a command "nm-tool" in Linux terminal will show me whether a Ethernet cable is plugged or not. If Ethernet cable is plugged, in the device part of eth0, the Hardware Link of Wired Settings will indicate a "yes" and "no" if no Ethernet cable. Hence, in my previous code, I use one function called popen to read the state as shown below:
PHP Code:
[code]....
However, now my project wish to not use the NetworkManager (where the "nm-tool" command comes from). And this gives me trouble to detect the Ethernet cable. So is there any other method for me to detect the Ethernet cable in C programming?
View 8 Replies
View Related
Jan 6, 2011
from the php or html webpages pages, can we find the direct link to the flv files. videos it is easy, ok, because it places with firefox the flv file into the temp. but what about all other streams of webcams, videos, music, ... so that one can use mplayer
View 1 Replies
View Related
Feb 20, 2010
I need to figure out if mythfrontend is non responsive. If the frontend was closed by accident, this code restarts it for me as a cron job.
#!/usr/bin/perl
use Env;
$ENV{DISPLAY}=':0';
my $result = `ps aux | grep front`;
[code]....
If I run the above code it works (mythfrontend restarts) however, there are times when the frontend becomes non-responsive and I'd like to detect a non-responsive state but I don't know how. Additionally, I don't have a keyboard on the mythfrontend, just the remote control.
View 2 Replies
View Related
Nov 25, 2010
I am working on scraping a sit e but during the authentication process (a form and user/password then submit) a javascript pop-up window comes up that needs to be pressed.I was planning on using www:mechanize but found out it doesnt do javascript.
View 2 Replies
View Related
Apr 6, 2011
I am having the following problem. The following code works fine on my P.C. Ubuntu x64, and on a jetway mini-itx board with an atom processor. The problem is, the same code doesn't work on the intel equivalent of the jetway board. I thought the maybe, I didn't have the port configured right, so I turned on Hardware Flow control and also tried turning on the modem bits I needed with TIOCMBIS. Neither worked. Here is the code. There are two threads, one of them, respsponding to the client, and using the RTS and DTR pins to power two relays. The other, manages listening to CTS and DSR for input. Here is the class with the first thread.
Code:
/*
* DigitalIOCore.cpp
*
* Created on: Nov 1, 2010
* Author: jonathan
[code]....
View 9 Replies
View Related
Aug 17, 2010
I am using a simple javascript to connect my flv streams with Red5 (streaming server) every thing is working perfectly fine in Mozilla and Chrome.
But when it comes to IE it simply wont load the player.
Here is my script code...
How do I detect the client browser and redirect him to adobe flash upgrade page if the client browser does not have a supported player?
View 4 Replies
View Related
Apr 1, 2011
I want to write a script that will detect all the unwanted files in a particular directory and delete them in one fly..
View 11 Replies
View Related