This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can't connect properly (TCP/IP)


> Here it is:
>         #include <network.h>
> ...
>         int Tcp_connectToServer()
>         {
>             int sock;
>             int n;
>             struct sockaddr_in serv_addr;
>             
>             sock = socket(AF_INET, SOCK_STREAM, 0);
>             if (sock < 0)
>             {
>                 //Error while open socket
>                 return -1; //TODO return types
>             }
>             
>             memset(&serv_addr,0,sizeof(serv_addr));
>             serv_addr.sin_family = AF_INET;
>             serv_addr.sin_addr.s_addr = htonl(0xC0A85001);
> //192.168.80.1
>             serv_addr.sin_port = htons(TCP_MAIN_PORT);      //5000
>             serv_addr.sin_len = sizeof(serv_addr);
>             
>             n=connect(sock,(struct sockaddr
> *)&serv_addr,sizeof(serv_addr));
>             if (n < 0)
>             {
>                 //Connecting Error
>                 return -1;
>             }
>             n=0;
>             
>             n = write(sock,"testcase",strlen("testcase"));
>             if (n < 0)
>             {
>                 //writing error
>                 return -1;
>             }
>             
>             return 0;
>         }

I would add some diag_printf() so you know what has been executed and
if there are any errors returned.

I would also use tcpdump/ethereal etc, to watch the packets flowing
backwards and forwards. You should be able to see this data in a
packet etc.

       Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]