Re: Error in accept() system call
From: Santosh Golecha (santosh_jain_at_acm.org)
Date: 08/14/03
- Next message: N.K.: "Wrong posting: Changing Hostname made my Linux Box go crazy, Correction here"
- Previous message: Hagit: "atm driver in linux"
- In reply to: nzwwbtyb_at_soszoe.com.jk: "Re: Error in accept() system call"
- Next in thread: beltorak: "Re: Error in accept() system call"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
> --
- Next message: N.K.: "Wrong posting: Changing Hostname made my Linux Box go crazy, Correction here"
- Previous message: Hagit: "atm driver in linux"
- In reply to: nzwwbtyb_at_soszoe.com.jk: "Re: Error in accept() system call"
- Next in thread: beltorak: "Re: Error in accept() system call"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|