C++ :: Implement Bidirectional Communication Between Two Processes?

Mar 29, 2012

I have two command line apps, one of them is multithreaded. I need to implement a bidirectional communication between them. Currently I can do

Code:
ProgramA 1> ProgramB

for the first programA to direct output into ProgramB, however I also need ProgramB to send messages to ProgramA.

how to implement it in a easiest way.

btw, I am on Ubuntu. I'd rather not to use third party libraries, Boost, etc.

View 7 Replies


ADVERTISEMENT

C/C++ :: Two Way Communication Between Child And Parent Processes (pipes)

Mar 19, 2014

I want parent and child processes to communicate in C linux using pipes. I have created two file descriptors. one for parent to child i.e. readpipe and other writepipe for viceversa. But I am getting null as output for ch and ch1 strings in my code below.

#include <stdio.h>
#include<stdlib.h>
#include
#include<unistd.h>
int main(){
pid_t pid;

[Code] .....

View 1 Replies View Related

C :: Pipes Between Child Processes

May 5, 2014

I wrote a C program that is supposed to create a certain number of child processes, each child process having to change 1 letter from a string. The string and the number of child processes are read from the keyboard. I want to do it using pipes.

It should work like this: The parent changes one letter, then the first child takes the string modified by the parent and changes one more letter. The second child takes the string modified by the first one (2 letters are already changed) and changes one more and so on. I am new to C and am not quite sure how it all works, especially pipes. Also can the children be linked between them through the pipe, or can they only be linked to the parent and it has to be something like: first child changes a letter, gives the string back to the parent and then the second child reads from there, modifies letter and gives back.

If it's like that, is there any way to make sure that this doesn't happen: Apples becomes AppleD and then AppleX and then AppleQ? For example:

Code:
Input: Apples
Output: Applex Appldx Aqpldx My problem is: I don't get any output from the children.

Here's my code:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
#include <sys/wait.h>

[Code] .....

View 2 Replies View Related

C++ :: Shared Memory Between Processes

Apr 13, 2014

Say now I have a dll, loaded and run by a 32bit program. One of the things that I access from the program in the dll are several 1024x1024 int buffers. However I would like to put some data into those buffers from a external process. And I would like a separate thread in that external process for each buffer. Is there any way I can make that memory space accessible to the external process so I can use my own multi threaded memory transfers to pass that data over provided I ensure that the original process doesn't try to do anything with that data? And I would like to do this without resorting to the Read/WriteProcessMemory functions which are not threadsafe. In short, I want to set up direct memory access between the 2 programs without creating any intermediate shared memory buffers ie I want to set permissions for an existing memory space. Is this possible?

View 1 Replies View Related

C :: Edge Detection Done Using Processes And Pipes

Nov 30, 2014

I don't think my processes are being created the way I want. I'm trying to create a fan of process (i.e. one parent with multiple children).

I want the parent to put together the final output image, and the children are supposed to do the edge detection on various regions of the image. Here is what I have:

Code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "iplib2New.c"
#define FILTER_SIZE 3
//Function prototypes

[Code] ......

View 10 Replies View Related

Visual C++ :: Getting A List Of Active Processes?

Apr 14, 2015

how to get a list of the active processes on a computer?

What I need to do is check for a specific process to see if it's running on the system.

I just need to know if a certain process is present.

View 1 Replies View Related

C++ :: Showing All Running Processes Like In Task Manager

Oct 7, 2014

I want to show all running processes of windows.

my motive is whenever any running process closes/quits whether it be console or window based on windows it notify(s) me or user that some .exe has been closed.

View 1 Replies View Related

C :: Create 9 Child Processes And Eventually Write From Each Process To Another?

Nov 18, 2013

I want to create 9 child processes and eventually write from each process to another. How can I specifically create 9 child processes and leave them running? Right now, I am using a loop from i=0 to i=8 and running fork() within that loop, but each child process also runs the loop, which spawns dozens (maybe hundreds?) of processes. I specifically only want to create nine of them. How can I do this?

Code:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>

[Code].....

View 7 Replies View Related

C/C++ :: Using Semaphores On Critical Region - Processes Not In Correct Order

Mar 2, 2014

I'm trying to use semaphores on three different processes so that each process won't enter the critical region at the same time and also go in the order: process 1 -> process 2 -> process 3. However, everytime i run the code the process 3 keeps going before process 2.

Here's my code:

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>

[Code].....

the processes should print out like this:

process 1: 100000
process 2: 300000
process 3: 600000

View 1 Replies View Related

C/C++ :: Shared Memory Project Not Getting Accurate Count For Processes

Jan 30, 2014

I'm working on a project that is supposed to create 3 processes. Process 1 should count from 1 to 100,000. Process 2 from 1 to 200,000. Process 3 from 1 to 300,000. I've written the basic code of it but my processes aren't printing out very accurate numbers.

Here's my code:

/*ass1*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <unistd.h>
/* change the key number */
#define SHMKEY ((key_t) 8450)
typedef struct

[code]....

View 4 Replies View Related

C :: USB To Serial Communication Using Language

Dec 18, 2013

I have to communicate between two laptops using USB-to-Serial adapter. I have written 2 programs one for sending and another for receiving. Programs were written in both C and C# programming languages.

Using C language: I am able to successfully communicate using C-Programs mentioned below. But the problem is speed. It takes around 1 hour(60min) for just to pass 150MB. improving the performance of this programs...I also mention some comments along with programs for self understanding.Sender File on laptop with serial port :

Code:

#include <stdio.h>
#include <bios.h>
#include <conio.h>
}

[code]....

The above 4 programs behaves as, sender send a character and receives an ack for every character. I have followed this approach, bcoz other approaches were not working fine (in the sense the complete data is not sent, the amount of data sent is not judgeable, bcoz it will different every tym). when i used this approach it worked fine.

View 6 Replies View Related

C++ :: Communication Between Functions Of Class

May 19, 2013

I have a class as follows:

class testa {
public:
testa_b();
~testa_b();
testa_c();
}

Then I have defined some variables in testa_b:

testa::testa_b()
{
double aa = 1.0;
}

What is the easiest way to make testa_c() can use the aa defined in testa_b() (without declaring them in the class)?

View 3 Replies View Related

Visual C++ :: COM Port Communication

Nov 30, 2012

How to communicate my COM PORT to my visual c++ ... Means i want to read data from my port and want to show in visual c++ so what to do ...

View 1 Replies View Related

C++ :: Two Way Event-driven Communication Between Objects

Oct 26, 2013

I need to implement a two-way asynchronous communication between two objects, not using any IPC.

What I have now is a producer-consumer model where producer sends a number "88" to consumer at random intervals. Now, I need consumer to send a number "99" back to producer at a random intervals, this probably should be done in a separate thread.

I am using GNU on Linux, here is the compile line.

Code:

g++ -g -std=c++11 main.cpp -o main

Code:

#include<iostream>
#include<chrono>
#include<thread>
class IObject {
public:
virtual void fromApp(int i) = 0;
virtual int toApp(int& i) = 0;// ???

[code].....

View 8 Replies View Related

Visual C++ :: Communication Between Two Programs Via Registry?

Jan 24, 2014

I'm trying to set up some basic communication between two programs via the registry.

For this I would like to use the functions

Code:
int value=10;
CString strSection="Data";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileInt(strSection,ValueName,value);
and

Code:
CString strSection="Data";
CWinApp* pApp = AfxGetApp();
int value=pApp->GetProfileInt(strSection,ValueName,0);
which read/write to the application's registry.

Is there some way of making two different programs use the same application registry?

View 14 Replies View Related

C :: Simple Way To Have Instant Communication In TCP/IP Chat Program?

Mar 25, 2014

My program allows a server and a client to chat over a socket. Currently I have to wait for one of them to type a message and press enter, before a message from the other person can be received.

Is there a simple way for messages to be received instantly - but not disturb any message that is being typed in?

View 2 Replies View Related

Visual C++ :: Manage Serial Communication With A Pedal

Jan 17, 2013

I wrote a class pedal that allows to search for the serial port on which the pedal is connected. Therefore I send a request to the pedal and set up a timer event of 20 ms. If no reply, I search for the next serial port.

When found I send configuration to the pedal and set another timer event of 200 ms that requests for pedal state. It runs fine.

Now if the pedal is disconnected then connected again I would like it to run again.

Therefore I set another timer event every 2s that launches all what I described above.

The trouble comes because the 20 ms timer event doesn't run and I do not understand why.

View 3 Replies View Related

C :: How To Capture And Store Serial Communication Data In Buffers

Jun 18, 2013

I sent 1preample and 4bytes in transmitting side , preample contains only 1 and 0 with 4milliseconds delay, each byte contains 8bits with 2milliseconds delay , if a bit contains 1 it will send 1millisecond high and 1millisecond low signal ,and if a bit contains 0 it will send 2millisecond continuous delay, I have a problem at receiving side how to capture and store the preample and 4byte values in a buffer , i am using ARM processor it will update every 5microsecond ..

View 1 Replies View Related

C++ :: SerialPort Communication - Reading Data From Port And Storing In One Document

Jun 27, 2014

I am doing SerialPort communication program where i am opening the port and reading data from port and storing in one document.

I debug my program and check that my read function is reading the data properly but when checking the document i find only unicode.

Suppose I am sending 1,2,3,4 to port i able to read same but my document showes þÿÿ þÿÿ þÿÿ þÿÿ

//My Read Function which read data from serial port
tInt serialport::Read(tVoid* pvBuffer, tInt nBufferSize) {
tInt nBytesRead = 0;

[Code] ....

Why I am getting unicode instead of 1,2,3,4 in my document ....

View 3 Replies View Related

Visual C++ :: Serial Communication In Windows - ClearCommError Finds No Data In Read Buffer

Dec 13, 2013

I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.

This is the relevant code in my desktop:

while(1) {
ClearCommError(hPort,&dwErrors,&commStatus);
if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL);
Sleep(10);
}

The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.

The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.

View 2 Replies View Related

C++ :: Publish Data Over The Internet In Peer To Peer Style Communication?

Sep 24, 2012

I need to be able to publish data between multiple machines at remote locations. I have been able to send data between two machines on a network in the same room. However, how to begin with resolving IPs for machines on other networks that are miles away etc. I would assume the application would need to LISTEN & PUBLISH in order to achieve this?

I have also googled this, and can only seem to find C# examples, and they seem to be for data between remote computers on the same network... What I need is to be able to find some guidance on sending data between me and someone who I previously had no knowledge of. I know this must be possible due to the fact that p-2-p chat clients exist, and that p-2-p file sharing exists.

View 1 Replies View Related

C :: How To Change MPI Broadcast Into Asynchronous Point To Point Communication

Jun 26, 2013

I have one code that use MPI broadcast and I want to change it into Asynchronous Point to Point communication. I am newbie in Parallel programming. Looking for implementation of one simple same program in broadcast and P2P ?

View 6 Replies View Related

C/C++ :: Client To Client Communication Using Network Programming?

Feb 8, 2015

I am trying to make kind of a messenger using Socket/Network Programming

My program should allow clients to register or sign in, after they are signed in they should see a list of the other signed in people whoever I select from that list I should be able to implement using multiple threads as well.

I have done this much:

User.txt file

ahsan,1234
bilal,1234
pappu,1234
babu,1234

Client.c

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

[code]....

Now issue is in this code I am getting error SEGEMENTATION ERROR, CORE DUMP

View 5 Replies View Related

Visual C++ :: PIC To PC Using MFC Visual Studio Through Serial Communication

May 28, 2014

The project is about reading data from PIC and display the data on the dialogue created by the MFC GUI of Visual studio 2010. There are 4 data need to be displayed (2 weight and 2 angle). the data will be display on the edit control box on the dialogue.

I have try to solve the COMPort and Readdata issues many times, but I'm fail. I have read many sources and implement the source codes... They are never work....

The detail about the issues that I need to solve is clearly mentioned on the main dialogue.cpp. Take a look to an uploaded zip file that I have attached.

View 6 Replies View Related

C :: How To Implement Vectorization

May 20, 2013

I'm trying to learn how to implement vectorization. Lets say I have this an array like this.

Code: int Array[10] = { 3,4,5,3,4,5,6,7,8,9};

If I traverse through the array and preform some simple calculation like adding numbers, how would I go about vectorizing this feat? For example if I want to add numbers, .

An example, add element at index 5,6,7 to element with index 1.

Code:
0 1 2 3 4 5 6 7 8 9 --- index
3,4,5,2,8,2,3,5,1,2 --- ints

View 6 Replies View Related

C :: Implement Setjmp For Function?

Feb 23, 2015

I am trying to implement setjmp for functions.

Code:
#include <setjmp.h>
#include <stdio.h>
jmp_buf arr[3];
void DISP(int x , int i)

[Code]....

Could I possibly use malloc to allocate memory for the stack too?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved