[Click] Help, about handler
wubaochuan
wubaochuan at seu.edu.cn
Thu Jan 20 00:23:38 EST 2011
Hi Beyers,
Thank you.
I have tried an example, but I always failed to connect to
ControlSocket.
I use test.click and client.c, after run *click test.click*, I
compile client.c, and run the client, but I always get the following
output:connect error: Connection refused. I examine the program
carefully, but I do not know what is wrong.
test.click:
//start of test.click
ControlSocket("TCP", 1234);
InfiniteSource(DATA \<00 00 c0 ae 67 ef 00 00 00 00 00 00 08 00
45 00 00 28 00 00 00 00 40 11 77 c3 01 00 00 01
02 00 00 02 13 69 13 69 00 14 d6 41 55 44 50 20
70 61 63 6b 65 74 21 0a>)
-> Strip(14)
-> Align(4, 0) // in case we're not on x86
-> CheckIPHeader(BADSRC 18.26.4.255 2.255.255.255 1.255.255.255)
-> Print(ok)
-> Discard;
//end of test.click
=======================================================================
client.c, a very simple program, connect to
//start of client.c
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
int sockfd;
int len;
struct sockaddr_in address;
int result;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
{
perror("socket() error");
exit(1);
}
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr("10.3.16.138"); // this is the
machine I run click, the program generated by click.c also runs on this
machine.
address.sin_port = 1234;
len = sizeof(address);
result = connect(sockfd, (struct sockaddr *)&address, len);
if (result == -1)
{
perror("connect() error"); // it always failed, always output:
*connect() error: Connection refused*
exit(1);
}
close(sockfd);
return 0;
}
//end of client.c
I can see click is listenning on port 1234 using following command:
netstat -ntlp | grep 1234
But why it always fails when I connect to this port ? Is there an
example can tell me how a client can connect to click's controlsocket ?
Thank you.
Yours
Chuan
More information about the click
mailing list