testbabelserver.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "config.h"
00024 #include <glib.h>
00025 #include <netinet/in.h>
00026 #include <stdio.h>
00027 #include <sys/stat.h>
00028 #include <sys/un.h>
00029 #include <unistd.h>
00030
00031 int main ()
00032 {
00033 char *args[] = {"babelserver", NULL};
00034 GError *error = NULL;
00035 g_spawn_async (NULL, (char **) args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL,&error);
00036 if (error) {
00037 g_error_free (error);
00038 error = NULL;
00039 }
00040 struct stat statbuf;
00041 while (stat ("/tmp/babelsocket", &statbuf));
00042 int babelsocket = socket (AF_UNIX, SOCK_STREAM, 0);
00043 if (babelsocket == -1) {
00044 perror("Could not create the socket");
00045 return FALSE;
00046 }
00047 struct sockaddr_un adr_serv;
00048 adr_serv.sun_family = AF_UNIX;
00049 strcpy (adr_serv.sun_path, "/tmp/babelsocket");
00050 if (connect (babelsocket, (const struct sockaddr*) &adr_serv, sizeof (struct sockaddr_un)) == -1) {
00051 perror ("Connexion failed");
00052 return FALSE;
00053 }
00054
00055 return 0;
00056 }