Code: Select all
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#define NOSTR 1
#define ADDRESS "/tmp/zm.sock"
char *str_arr[NOSTR] ={
"1|on+10|1|Snapshot|text"
};
main()
{
char c;
register int i, sh, len, ch;
struct sockaddr_un saddr_un;
if ((sh = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
perror("socket");
exit(1);
}
saddr_un.sun_family = AF_UNIX;
strcpy(saddr_un.sun_path, ADDRESS);
len = sizeof(saddr_un.sun_family) + strlen(saddr_un.sun_path);
if ((ch = connect(sh, (struct sockaddr *) &saddr_un, len)) < 0)
{
perror("connect");
exit(1);
}
for (i = 0; i < NOSTR; i++)
{
if (send(sh, str_arr[i], strlen(str_arr[i]), 0) < 0)
{
perror("send");
exit(1);
}
}
close(sh);
exit(0);
}
"netstat -anp" shows this after the client exits:
Code: Select all
unix 2 [ ACC ] STREAM OUVINDO 16989 5778/perl /tmp/zm.sock
unix 3 [ ] STREAM CONECTANDO 0 - /tmp/zm.sock
So the connection never passed from "connecting" to "connected". Strange enough, a minimalistic socket server I wrote accepts the connection like a charm and receives the data OK.
Could anybody push me in the right direction?
Thanks
Juergen