je suis pour la manipulation des vsockets et j'ai rencontrés plusieurs problémes tels que les problème suivant :
le programme exit et je ne sais pas pouquoi .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <errno.h>
#include <getopt.h>
#define VERSION			"0.0.0"
#define DEVDIR			"/dev"
#define DEV_LIRCD	"lircd"
#define LIRCD			DEVDIR "/" DEV_LIRCD
static struct option long_options[] =
{
	{"help", no_argument, NULL, 'h'},
	{"version", no_argument, NULL, 'v'},
	{0, 0, 0, 0}
};

int main(int argc,char *argv[])
{
	int fd,i,inc, keyRet, run = 1;
	char buf[128],buf_copy[128], oldKey[128], dis[100];
	struct sockaddr_un addr;
	int c;
	char *progname, *pch;

	progname="irw " VERSION;

	addr.sun_family=AF_UNIX;

	strcpy(addr.sun_path,LIRCD);

	fd=socket(AF_UNIX,SOCK_STREAM,0);
        printf("déclaration de la socket\n");
	if(fd==-1)  {
		perror("socket");
		exit(errno);
	};
	printf("le fd est %d",fd);
	if(connect(fd,(struct sockaddr *)&addr,sizeof(addr))==-1)  {
		perror("connect");
		exit(errno);
	};
	printf("avant memeset \n");
	memset(oldKey, sizeof(oldKey), 0x00);
	printf("avant la boucle\n");
	while(run)
	{
		
		i=read(fd,buf,128);
		if(i==-1)
		{
			perror("read");
			exit(errno);
		};

		if(!i)  exit(0);//*le programme exit à ce point est i une valeur négative trés grande est ce que vous 								avez une explication merci*/
		
		//Parser le buf;
		memset(buf_copy, sizeof(buf_copy), 0x00);
		strcpy(buf_copy, buf);
		pch = strtok (buf_copy," ");
		inc = 1;
		while (pch != NULL)
		{
			inc++;
			pch = strtok (NULL, " ");
			sprintf(dis, "inc = %d  ;  pch = %s\n", inc, pch);
			if (inc == 3)
			{
				sprintf(dis, "inc = %d  ;  pch = %s\n", inc, pch);
				write(STDOUT_FILENO,dis,strlen(dis));
			}
			
		}

		};
}
Important :
fd = 3 ;
connexion = 0 ;;;donc établie
i= valeur négative trés grande