Is to run two programs in the Code::Blocks? Its run each in a prompt?
13 replies to this topic
#1
Posted 03 November 2010 - 05:06 AM
|
|
|
#2
Posted 03 November 2010 - 06:57 AM
Hi,
Did you mean that you want to run process from your program.
1. On Windows you can use CreateProcess, ShellExecute functions to run a process.
CreateProcess Function (Windows)
ShellExecute Function (Windows)
2. On Linux, you can use fork and exec functions to run process.
Fork, Exec and Process control
I hope this helps
Munir
Did you mean that you want to run process from your program.
1. On Windows you can use CreateProcess, ShellExecute functions to run a process.
CreateProcess Function (Windows)
ShellExecute Function (Windows)
2. On Linux, you can use fork and exec functions to run process.
Fork, Exec and Process control
I hope this helps
Munir
#3
Posted 03 November 2010 - 09:30 AM
I don't think he's asking about threads. In Code::Blocks you can have multiple files opened but you can only run one via their console. You can compile others and start them manually.
A conclusion is where you got tired of thinking.
#define class struct // All is public.
#4
Posted 04 November 2010 - 05:16 AM
mnirahd said:
Hi,
Did you mean that you want to run process from your program.
1. On Windows you can use CreateProcess, ShellExecute functions to run a process.
CreateProcess Function (Windows)
ShellExecute Function (Windows)
2. On Linux, you can use fork and exec functions to run process.
Fork, Exec and Process control
I hope this helps
Munir
Did you mean that you want to run process from your program.
1. On Windows you can use CreateProcess, ShellExecute functions to run a process.
CreateProcess Function (Windows)
ShellExecute Function (Windows)
2. On Linux, you can use fork and exec functions to run process.
Fork, Exec and Process control
I hope this helps
Munir
How does these functions? Can I put the server to run in a process and the client in another?
#5
Posted 04 November 2010 - 05:27 AM
Hi,
Yes, you can create any process from any process using the function I mentioned above.
Could you please explain me a bit what you're actually trying to achieve specifically so I could help with that?
Munir
Yes, you can create any process from any process using the function I mentioned above.
Could you please explain me a bit what you're actually trying to achieve specifically so I could help with that?
Munir
#6
Posted 04 November 2010 - 06:17 AM
mnirahd said:
Hi,
Yes, you can create any process from any process using the function I mentioned above.
Could you please explain me a bit what you're actually trying to achieve specifically so I could help with that?
Munir
Yes, you can create any process from any process using the function I mentioned above.
Could you please explain me a bit what you're actually trying to achieve specifically so I could help with that?
Munir
I have two programs. Server program and one client program. I want to simulate the connection between client-server
Just what I need to run the server and leave him waiting for the client to initiate the connection
#7
Posted 04 November 2010 - 06:22 AM
Hi,
I understand what you're trying to do, but I'm unable to figure out what problem you're facing. You can simply run the server process, and then run the client application to simulate the connection.
Munir
I understand what you're trying to do, but I'm unable to figure out what problem you're facing. You can simply run the server process, and then run the client application to simulate the connection.
Munir
#8
Posted 04 November 2010 - 01:23 PM
mnirahd said:
Hi,
I understand what you're trying to do, but I'm unable to figure out what problem you're facing. You can simply run the server process, and then run the client application to simulate the connection.
Munir
I understand what you're trying to do, but I'm unable to figure out what problem you're facing. You can simply run the server process, and then run the client application to simulate the connection.
Munir
"You can simply run the server process, and then run the client application to simulate the connection"
It is just that, only need to run everything on a single project, so I must have only one main
#9
Posted 04 November 2010 - 02:32 PM
Hi,
Ok - then you can use the functions as I suggested.
Use CreateProcess on Windows
Use fork, and exec on Linux.
you can see the links I've posted above, and that would surely help you to achieve the results you want.
Munir
Ok - then you can use the functions as I suggested.
Use CreateProcess on Windows
Use fork, and exec on Linux.
you can see the links I've posted above, and that would surely help you to achieve the results you want.
Munir
#10
Posted 04 November 2010 - 03:08 PM
mnirahd said:
Hi,
Ok - then you can use the functions as I suggested.
Use CreateProcess on Windows
Use fork, and exec on Linux.
you can see the links I've posted above, and that would surely help you to achieve the results you want.
Munir
Ok - then you can use the functions as I suggested.
Use CreateProcess on Windows
Use fork, and exec on Linux.
you can see the links I've posted above, and that would surely help you to achieve the results you want.
Munir
I have a main.cpp:
#include "ExceptionSocket.h"
#include "ClientSocket.h"
#include "ServerSocket.h"
#include "Socket.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char** argv)
{
//Server
cout << "Run...\n";
try
{
ServerSocket server(10000);
while(true)
{
ServerSocket n_sock;
server.accept(n_sock);
try
{
while(true)
{
string data;
n_sock >> data;
n_sock << data;
}
}
catch(ExceptionSocket&) {}
}
}
catch(ExceptionSocket& e)
{
cout << "The exception was detected:" << e.description() << "\nLeaving...\n";
}
//Client
try
{
ClientSocket client("localhost", 10000);
string reply;
try
{
client << "Test message";
client >> reply;
}
catch(ExceptionSocket&) {}
cout << "We received this response from the server:\n" << reply << "\n";
}
catch(ExceptionSocket& e)
{
std::cout << "The exception was detected:" << e.description() << "\n";
}
return 0;
}
I think I need to create a process for the server and run the client. Am I right? Just do not know how, I do not quite understand the function CreateProcess
#11
Posted 05 November 2010 - 03:54 AM
Any ideas?
#12
Posted 06 November 2010 - 03:42 AM
Hi,
I'd suggest you to create 3 projects
1. Server Application
2. Client Application
3. Simulation Application
The Simulation Application should create first Server Process, and then after a delay of few milli seconds, create Client Process. I believe this should help you.
Munir
I'd suggest you to create 3 projects
1. Server Application
2. Client Application
3. Simulation Application
The Simulation Application should create first Server Process, and then after a delay of few milli seconds, create Client Process. I believe this should help you.
Munir
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









