Re: Error in accept() system call

From: Santosh Golecha (santosh_jain_at_acm.org)
Date: 08/14/03


Date: 14 Aug 2003 08:52:19 -0700

Thanks...it worked. The only change I made as per your recommendation
was to add the following statement before the accept system call.

clilen = sizeof(cliaddr);

Thanks
 

nzwwbtyb@soszoe.com.jk wrote in message news:<tED_a.33167$bo1.16542@news-server.bigpond.net.au>...
> Try this:
>
> | }
> |
> | for( ; ;) {
> clilen = sizeof(cliaddr);
> | if(( nsockfd = accept(sockfd ,(struct sockaddr *) &cliaddr
> |, &clilen) ) < 0 )
> | {
>
> See this paragraph in man 2 accept for the reason.
>
> The argument addr is a pointer to a sockaddr structure. This structure
> is filled in with the address of the connecting entity, as known to the
> communications layer. The exact format of the address passed in the
> addr parameter is determined by the socket's family (see socket(2) and
> the respective protocol man pages). The addrlen argument is a value-
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> result parameter: it should initially contain the size of the structure
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> pointed to by addr; on return it will contain the actual length (in
> ^^^^^^^^^^^^^^^^^^^^^
> bytes) of the address returned. When addr is NULL nothing is filled in.
>
> By the way if you compile with -Wall you will notice lots of warnings
> which you should fix if you really want your code to be portable. Also
> note that inet_addr is deprecated and it returns the wrong type for
> assignment to sin_addr anyway.
> --



Relevant Pages

  • Re: dynamic allocation of new objects
    ... I'm trying to make a function which dynamically allocates new objects ... and returns a pointer to them. ... value: 10 addr: 134520840 ... can anyone help me get the same in fortran as I get in c, ...
    (comp.lang.fortran)
  • Re: Memory map and acces in Microblaze
    ... Create one register based at BASEADDR. ... Xuint32 pointer=USE_ADDRES; ... Addr = 83000028 data = B ... Fix the declaration for 'pointer' and try again. ...
    (comp.arch.embedded)
  • Re: Error in accept() system call
    ... The argument addr is a pointer to a sockaddr structure. ... addr parameter is determined by the socket's family and ...
    (comp.os.linux.networking)
  • [PATCH 3/9] module: remove module_text_address()
    ... module_text_addressreturns a pointer to the module, which given locking ... is useless except to test for NULL: ... bool is_module_address(unsigned long addr); ...
    (Linux-Kernel)