summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordeva <deva>2005-04-19 18:33:29 +0000
committerdeva <deva>2005-04-19 18:33:29 +0000
commit6e952aa069f0a78d6f784d4c132969a2bb63acb7 (patch)
tree95c9bd94a656ff92952164a48806a62f04008364 /src
parent7af06f473e99f02a0cb8978aee67a61b5718664d (diff)
Server part works again.
Diffstat (limited to 'src')
-rw-r--r--src/miav.cc16
-rw-r--r--src/server.cc24
2 files changed, 20 insertions, 20 deletions
diff --git a/src/miav.cc b/src/miav.cc
index cfd8770..c441dca 100644
--- a/src/miav.cc
+++ b/src/miav.cc
@@ -40,6 +40,7 @@ enum {
MODE_SERVER
};
+
/**
* This function starts the MIaV gui.
*/
@@ -55,6 +56,7 @@ int grab(int argc, char *argv[]) {
#endif /* USE_GUI */
}
+
/**
* This function starts the MIaV server.
*/
@@ -71,11 +73,11 @@ int server(int argc, char *argv[]) {
}
printf("Listening on port %d\n",atoi(argv[0]));
- Socket *s = new Socket(atoi(argv[0]));
+ Socket *socket = new Socket(atoi(argv[0]));
while(1) {
- Socket *sc = new Socket(s->slisten());
- if(sc->isConnected()) {
+ Socket *csocket = new Socket(socket->slisten());
+ if(csocket->isConnected()) {
childpid = fork();
if(childpid == -1) {
@@ -84,16 +86,16 @@ int server(int argc, char *argv[]) {
exit(1);
} else if(childpid == 0) {
// fork() returns 0 to the child process
- delete s; // Close listen socket.
- newConnection(sc);
- delete sc; // Close communication socket.
+ delete socket; // Close listen socket.
+ newConnection(csocket);
+ delete csocket; // Close communication socket.
exit(0);
} else {
// fork() returns new pid to the parent process
}
}
}
- delete s;
+ delete socket;
return 0;
}
diff --git a/src/server.cc b/src/server.cc
index e94b576..3370586 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -76,21 +76,20 @@ MovEncoder *newMovEncoder(char* cpr)
return enc;
}
-void newConnection(Socket *s)
+void newConnection(Socket *socket)
{
n_savestate savestate = LATER;
n_header h;
- Frame *f;
+ Frame *frame;
Frame *freeze_frame = NULL;
MovEncoder *enc = NULL;
- // FIXME: Allocate buffer
- f = new Frame(NULL, 0);
+ frame = new Frame((unsigned char *)malloc(DVPACKAGE_SIZE), DVPACKAGE_SIZE);
printf("New connection[pid: %d]...\n", getpid());
- Network n = Network(s);
- while(int ret = n.recvPackage(&h, f->data, DVPACKAGE_SIZE)) {
+ Network network = Network(socket);
+ while(int ret = network.recvPackage(&h, frame->data, DVPACKAGE_SIZE)) {
if(ret == -1) {
fprintf(stderr, "An error occurred...!\n");
break;
@@ -108,13 +107,13 @@ void newConnection(Socket *s)
delete freeze_frame;
freeze_frame = NULL;
} else {
- saveFrameAsImage(h.header.h_data.cpr, f);
+ saveFrameAsImage(h.header.h_data.cpr, frame);
}
}
if(h.header.h_data.record) {
if(!enc) enc = newMovEncoder(h.header.h_data.cpr);
- enc->encode(f);
+ enc->encode(frame);
}
if(h.header.h_data.savestate) {
@@ -123,18 +122,17 @@ void newConnection(Socket *s)
if(h.header.h_data.freeze) {
if(freeze_frame) delete freeze_frame;
- freeze_frame = f;
+ freeze_frame = frame;
} else {
- delete f;
+ delete frame;
}
- // FIXME: Allocate buffer
- f = new Frame(NULL, 0);
+ frame = new Frame((unsigned char *)malloc(DVPACKAGE_SIZE), DVPACKAGE_SIZE);
}
// TODO: Use save state
- delete f;
+ delete frame;
if(enc) delete enc;
printf("Connection end[pid: %d]...\n", getpid());