[Click] Help, about handler

Cliff Frey cliff at meraki.com
Thu Jan 20 00:38:36 EST 2011


Can you telnet to that port with the command

telnet 127.0.0.1 1234

or

telnet 10.3.16.138 1234

or

echo "read config" | nc localhost 1234

?

This will help us see if the problem is with your client.c or with the way
you are running click.

I can connect to a control socket by running the following commands (my
input is in bold)

bug:~/co/click/build$ *./userlevel/click -p 3344 -e "Idle;" &*
[1] 21303
bug:~/co/click/build$ *telnet localhost 3344*
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Click::ControlSocket/1.3
*read config*
200 Read handler 'config' OK
DATA 5
Idle;
*quit*
200 Goodbye!
Connection closed by foreign host.

alternately, the same thing works if I run click this way instead:
*./userlevel/click -e "ControlSocket(TCP, 3344); Idle;"*
*
*
Cliff

On Wed, Jan 19, 2011 at 9:23 PM, wubaochuan <wubaochuan at seu.edu.cn> wrote:

> 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
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>


More information about the click mailing list