Programming :: Possible To Pass File D Escriptor Without Sockets / Streams?

Apr 20, 2010

I have a problem passing a file descriptor from one process to another.

I have two processes A and B. Both are running in different network and
filesystem namespaces, so it is impossible to use unix domain sockets or
net sockets to pass a file descriptor from process A to process B.

The usage of STREAMS is also impossible, as you can see in

[quotation begin]
Linux doesn't have STREAMS, which are the System V way
of doing this task. ...
[quotation end]

Are there additional possibilities for file descriptor passing like
using named pipes or something like that or does anybody know
a good workaround for this problem ?

View 9 Replies


Programming :: Grep Multiple Values In Single Pass Through Log File?

Nov 13, 2010

I have a huge binary log file. There are lets say 4 id's that I want to find in a log file. I know that those 4 id's will be present in the log file and I also know in what order they will be present. I want to find 1st id from the log then 2nd id and then third id and so on..

Simple/inefficient solution is: Loop through the id's and then grep in the log file. Problem with this solution is for each id grep will search from the beginning of the file.

Better/efficient solution would be: Sine I know the order in which id's will be present in the log file. Loop through id's, grep 1st id and then move on to grep 2nd id and so on...this way I can grep all id's in one pass. Is this solution possible ?

I have 500000 + values to find in log files and I have to find efficient solution for it.

View 2 Replies View Related

Programming :: Writing Unix Shell Script To Pass File Name/path/creation Date?

Oct 7, 2009

I'm new to UNIX scripting; I�m stuck with the following I have an Oracle SQL script that takes three parameters

1- File Name
2- File Path
3- File creation date

Under UNIX I have a folder where files will be placed frequently and I need to upload those files to Oracle, what I need is a UNIX script that can do the following

Loop through Directory "/home/applmgr/snktmp"
Picks only files
Pass the file name to parameter &1


Is the above possible? I already knows how to call the Oracle Script from UNIX Im only stuck on writing the UNIX part where it List the files attribute(name,path,date) and store them to parameters ,Looping until the last file in the directory If the above is not possible,then how can I create the below from the command line

Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate

View 4 Replies View Related

Programming :: PING Using Raw Sockets In C?

Nov 18, 2010

Is there any way to implement a simple ping script in C (unix)? I'm programming simple OpenWRT scripts.

I have found some examples of ping in C:


However, nothing happens, nothing is sent.

When I look at the code, in the portion where the socket is created, I can see that the socket is not binding to any interface:

if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) == -1)
setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &optval, sizeof(int));

Instead, it uses "setsockopt" to set some options.

My guess is that it is trying to send packets over the eth0 interface instead over the wl0 (wireless) interface (which is the one I want to use to send pings).

Now, my question is: Is there any other way to send pings in C by binding to an interface?

View 1 Replies View Related

Programming :: C/C++ - Program Detecting New Sockets

Jul 25, 2010

I need to create a C/C++ program in Linux that succeeds in detecting how many tcp-sockets and what tcp-sockets are created by the other processes in the system in a particular time interval (e.g., the interval time this application is running in). Then, I'd need to get some information like local/remote port number and local/remote ip address of each of these sockets.

View 8 Replies View Related

Programming :: How To Use Sockets To Display GUI At Server End

Aug 27, 2010

I am struggling a little on how to best approach this problem. I have wrote a server program that runs via xinetd, that obviously spits out data at the client end. Fairly straightforward stuff?There is a point in my server code where I need to display an image/gui i.e something that runs on X11 that prompts a user to perform a task on the display connected at the the server side.So far I have written a test program that displays some text at the client end and then launches the browser at the server end. I have also set the following export. Code: export DISPLAY=:0 and then goes on to launch my web browser. Works great when ran locally on the server and when I remotely telnet in to the server and run the code.

However when I try to run the same piece of code as a xinetd service the export seems to have zero affect and the client terminal window displays errors associated with there not being a X11 server running.The code launches fine when I create a socket to serverip:6556 it just the ability to display gui programs to another display that does not seem to be working.

View 5 Replies View Related

Programming :: Send A Packet Through Sockets C++

Feb 1, 2011

Can someone help me with this problem,trying to send a packet,using tcp/ip,the packet should look like this:

field 1: SOCKS protocol version, 1 byte (0x05 for this version)
field 2: status, 1 byte:
0x00 = request granted
0x01 = general failure
0x02 = connection not allowed by ruleset
0x03 = network unreachable
0x04 = host unreachable
0x05 = connection refused by destination host
0x06 = TTL expired
0x07 = command not supported / protocol error
0x08 = address type not supported
field 3: reserved, must be 0x00
field 4: address type, 1 byte:
0x01 = IPv4 address
0x03 = Domain name
0x04 = IPv6 address
field 5: destination address of
4 bytes for IPv4 address
1 byte of name length followed by the name for Domain name
16 bytes for IPv6 address
field 6: network byte order port number, 2 bytes
and this is my code:

int domainLen = strlen(domain);
char reply[domainLen + 7];
reply[0] = 5; // version
reply[1] = 0; // succed
reply[2] = 0; // reserved
reply[3] = 3; // its a domain
reply[4] = domainLen;; // lenght of domain
for(int j = 0; j < domainLen; ++j)
reply[j + 5] = domain[j];
reply[5 + domainLen] = 80; // port
reply[20] = '�';
Send(reply, sizeof(reply));
domain is "". Am I doing it right ? I dont know much about bits.

View 6 Replies View Related

Programming :: Parallel Data Transfer Using Sockets

Feb 25, 2011

I am doing a project where 2 clients connect to server and communicate (chat) and transfer data one after other using sockets. I have working code for this in C language. Now our main aim is to create a communication link where two clients transfer multiple streams data parallely. To be more precise i want to transfer images files and audio files parallel at same time, so is it possible to send data parallel using one socket connection?

View 3 Replies View Related

Programming :: Creating 2 Sockets In Client / Server?

Jun 9, 2010

I have a problem creating my second socket in client file. the program was running well but when I try to add another socket to connect to the same server, I got a problem connecting to the first socket! it doesn't make sense. the original code was:

sockfd[i] = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd[i] < 0) error("(MAIN) - Error openning socket 1");
port_num[i] = portno;
bzero((char*) &serv_addr[i], sizeof(serv_addr[i]));


View 1 Replies View Related

Programming :: Read DNS Informaton Using Sockets And C Libraries

Jun 9, 2010

I am using the API libpcap in order to filter the traffic of the port 53 from my PC ro other PCs, in other words the DNS traffic.I want to get more information about the DNS traffic that is being sent to the DNS server, in other words the queries. So far I have no idea how to read the information data or payload of the UDP package in order to read the content of the traffic for example if there is any PTR, A, MX, etc Resource Record.According to the RFC 1053 there is a header that is possible to use in order to easily get this info.

View 5 Replies View Related

Programming :: Automated Monitoring Of Different Sockets For Available Data

Feb 4, 2011

NextPendingConnection () returns a new socket with respect to a new client. This new QSocket is passed to the connect () function which connects it to a SLOT 'xyz' with SIGNAL 'readyRead()'. Now in the SLOT 'xyz' how I am supposed to automate the monitoring of ALL connected sockets to see whether some data is available on them? One pathetic way would be to run all the sockets through a for loop and check each one of them for the data. Secondly, I read up on QSocketNotifier() here: [URL]. But I am not sure if that is the correct thing.

View 3 Replies View Related

Programming :: Sending Binary Data Through Sockets In C

Nov 29, 2010

I am coding a http server which has to send the file(s) such as images, .avi files, .mpeg, that the client is going to request. I have been trying of sending files through sockets.

char info [256];
bzero(info, 256);
read(socket, info, 255);
write(socket, HTTP, 255);
FILE *fl= fopen(info,"rb");
fseek(fl, 0, SEEK_END);
long len = ftell(fl);
printf("largo: %ld", len);
unsigned char *ret = (char*) malloc(len);
fseek(fl, 0, SEEK_SET);
fread(ret, 1, len, fl);

However, it's supposed to be shown in Mozilla Firefox (as the client). But it is not doing it, so.. It's just not getting the complete file.

View 1 Replies View Related

Programming :: Mplayer Play Flash Streams - How To Detect The URL

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

Programming :: Multiplexing 2 Streams To Tx Over Wireless & Demulteplexing On Rx To Individual O/P

Jan 24, 2011

HOW to Go about the Linux Programming of DATA FUSION

Need to Multiplex ( Mux ) two Data Streams broadcast over Wireless and then Demultiplex (DeMux )on the Receiving side and give output on Individual O/p Screens. : DETAILS ::

My main PROJECT is,
1) First Stream :: GPS Stream
2) Video Stream :: Conversion of Analog Signal to Digital ( Using Compression Divx :: Not an issue )

Tx : Merging the Two Streams ( Mux ) and then Transmitting over Wireless as a Single Stream.
Rx : DeMux the Stream and Display GPS Data on Different O/P Screen and Video Stream on Different O/P Screen.

For now A Terminal on Both Ends can perform the Function with a OS in the Later Stages it will be embedded.

View 1 Replies View Related

Programming :: Closing Multiple Client Sockets In Server ?

Nov 30, 2010

I have written a server application which has select for both incoming new client connection requests and incoming data from client. I am able to process incoming connection requests and client data.

For example, server has 8 clients connected to it. If client 3 disconnects from server, how will server come to know this client has disconnected and to close its client socket fd gracefully? Does server's select get data on that client socket fd as 'close' data or any error code in recv() function that notifies server to close this client socket fd? Also if client disconnects abruptly without sending close request to server, how should server handle this? Does server get "EPIPE" error?

View 1 Replies View Related

Programming :: Send A Request To A Http Server Without Using Sockets.

Jul 8, 2011

Hi, is it possible to send a request to a http server without using sockets?

View 7 Replies View Related

Networking :: How To Send A File Using Sockets ?

Jun 25, 2010

Hi ,

I created a socket.port no 21 meaning ftp client.
I am sending some stings and receviing some data from server.Fine.

But I want to send a file some x.c to host using socket.
Please can someone help me whether we can do it or not.
If we can how can we send a file.I was only able to send buffer and data but not a file.Please if possible can you help me with example.


View 2 Replies View Related

Programming :: Passing Input To Processes As Streams (language-neutral)?

Jun 5, 2009

I am trying to figure out if there is a way to start a process, and while it is running, pass input to it as though it were a stream. Although the subject of this post mentions this question is "language-neutral", specifically, I am trying to do this in Common Lisp. Truly, I am looking for the principles behind the method of doing this, which seem to me as though they would be language neutral.

I have done Google searches, and found nothing relevant to my query. Without using sockets and IP communication, I would like to start a process (let's use the MySQL command-line client, for example) and then in my Common Lisp (CL) program, pass it input like so:


(format *mysql-client-instance* "SELECT * FROM some_table;")

Simply, how would I go about sending input to an active process as though it were a stream? My thinking is there has to be some way to do it - similar to the Expect superset of Tcl.

View 2 Replies View Related

Programming :: Play Multiple Sound Streams On ALSA Dmix?

Jul 31, 2010

I'm having trouble getting ALSA to play multiple sound streams (multiple sounds at once). My code is running on an embedded ARM board using a AC97 sound. It will only play one without any mixing, I have to use pure ALSA as higher sound mixers are a nightmare to cross compile for ARM. I've tested my system with aplay for example

aplay -D plughw:0,1 bang.wav

works fine. So I tried dmix with

aplay -D plug:dmix Win.wav

That gave the following error

ALSA lib pcm_direct.c:1587snd_pcm_direct_parse_open_conf) The field ipc_gid must be a valid group (create group audio)
aplay: main:550: audio open error: Invalid argument

I checked asound with

/etc # cat asound.conf
pcm.EP93XX {
type hw


Does this mean dmix will not work? Is there someway with the above setup I can play multiple sounds? I have to use the vendor ALSA build (so can't update ALSA), I can change the .confs however. Also because I'm cross compiling things like pulseaudio SDL are very difficult to get working, so I basically need to use the above ALSA. Is there anyway I can find if dmix exists on the system?

Should add aplay -L does show dmix ?
iec958 'cards.pcm.iec958'
spdif 'cards.pcm.iec958'


View 3 Replies View Related

Programming :: Sockets - P2 - P3 Http Connection Taking More Time Than The Expected?

Mar 31, 2011

Iam using socket programming in one of my problem. The scenario is like this.

=>one module is working as a socket server(process p1) is able to handle client sockets on that port.
=>one module is working as socket client (process p2) is connected to server socket and Tx/Rx data on this socket. This module has some more threads, based on received data from server socket it will connect to http on other thread and get information...
=>one more module is working as socket client (process p3) is also connected to server socket and doing some other transactions.

Here my problem is when in presence of p2, p3 http connection taking more time than the expected. If we wont start p3(means only one server-client socket) then http connection is fast enough.

View 1 Replies View Related

Programming :: While Receiving Can Use Functions Like Strchr() To Differentiate These Fields For Sockets?

Apr 15, 2009

constructing a protocol where in it involves sending and receiving different files, so sending data over consists of file name, size of the file and content of the file, so while receiving can i use functions like strchr() to differentiate these fields for sockets? so to allocate memory for file to save i need to have its size.

View 3 Replies View Related

Ubuntu Multimedia :: Combining Streams Of Video Into One File?

Feb 6, 2011

I'm looking for a program of some kind that I can combine 4 (if not 2 minimum) streams of video into one file. The only program so far that I've found that does this is avisynth but I can't seem to make it work at all. Does it even work under ubuntu? I've tried numerous guides and how to's but nothing seems to be working.

Basically I just need something that will take a video file, from several different sources (cameras placed around a car) and be able to place them in a grid form into one file. Basically in a format like this, where each letter is a different video file:
a b
c d

View 5 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

Programming :: Add Local Sockets In Multi-threaded Application In Order To Exchange Data Between Threads?

Jul 24, 2010

I'm trying to add local sockets in my multi-threaded application in order to exchange data between threads. The only problem I got is that most of the information available on the net is related to internet oriented socket programming whileI want to perform local connections. got a thread that does the sniffing via libpcap. And I would like that thread to send each captured packet to a second thread that will analyse the packetof the thread implementations is written in separate .h file.Or maybe there is a more effective method of exchanging data between threads

View 14 Replies View Related

Programming :: C++ Failing To Pass By Value?

Jan 25, 2010

I have a strange problem with a simple program. I have a container class that holds a pointer. I did this so I could use another container class that does several pass by value calls. I didn't want to be copying the object over and over again, so decided to build this simple container that simply copied the pointer in the copy constructor.

However, the pass by value call seems to be failing in a strange way. When the pass-by-value function is called, the program jumps into the copy constructor just fine and performs the pointer assignment operation. The program will copy the pointer value 0x20 (for argument sake) to the "this->base" location. Within the copy constructor, this has the address 0x28. Then when it jumps into the function, instead of pass by value argument being at 0x28 (as expected), it is at 0x36. Then 0x36->base has the address 0x28. Thus the base is now pointing at what was the new pointer container. At this point the data is corrupted and random things happen.

It seems that there is some strange assignment and double nesting going on. I really do not understand what is going on.

Below is some code. I have stripped away all the other code trying to isolate the problem. I have added comments explaining what my debugger is telling me.

using namespace std;
class paramPnt // Need to determine how order is tracked
long order;


View 4 Replies View Related

Programming :: JNI - How To Pass STL Structures

Jun 17, 2011

I hace some code C/C++ STL, which i need to use for android, using problem is that i need to pass some STL structures across JNI, I can't pack/unpack data into basic types or arrays of basic types, doing my own simple streaming between the two layers.My application need to pass a pointer to a STL structure which is updated by eachuser interaction wonder if it is possible using NDK-JNI ?Other option is "native activity" but it also needs JNI in some way ... and passing the STL structures wille a requirement, yet.I only can package data into an own streaming if there is a second (concurrent) application running (implementing the STLfunctionality). Is it possible ?

View 1 Replies View Related

Programming :: Pass Variable Between Scripts?

Mar 9, 2011

I need to pass variable from to and update the value of the passed variable in and then return the updated value of the variable from to

View 7 Replies View Related

Programming :: Pass In Mandatory Arguments First?

Jun 9, 2011

I am using getopts to take parse optional arguments but i also pass in mandatory arguments first

perror "$@"
shift 2

View 8 Replies View Related

Programming :: Pass A Path As A String To A Variable?

Apr 17, 2009

I'm trying to pass a path as a string to an array, but its evaluating it as a command instead. I want to take the literal string "/mnt/accounts/user/temp/*.jpg" and assign it to an array{1}, but when i echo the array variable, it displays it as



I just want it to be the actual text "/mnt/accounts/user/temp/*.jpg" which i will be combining with other text to create a longer path elsewhere in the code.

View 5 Replies View Related

Programming :: Pass Arguments To A Function Using A Loop

Mar 1, 2010

I need to pass a large number of arguments to a function which takes variable number of arguments, such as gtk_list_store_new. But it doesn't look nice if i write something like gtk_list_store_new(NUM,TYPE_A,TYPE_B,TYPE_C,...,TYPE_OMEGA); because of large number of arguments. And, it will be a trouble to change number of columns because of need to manually change arguments to large number of such functions. So, how can i pass all the arguments to a function using a loop? Something like


Of course, i could just use asm code for this, but is there a portable way of doing so?

P.S. i mean C language.

View 2 Replies View Related

Copyrights 2005-15, All rights reserved