[ale] Re: IPv6 programming question

Srikanth Pokkuluri Srikanth.Pokkuluri at lntinfotech.com
Mon Nov 5 22:42:01 EST 2007


Thanks a lot chuck..

Thanks and Regards,
P.V.S Srikanth
L&T Infotech.
Project Leader.
Employee No: 279753


Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com

This Document is classified as: 

L&T Infotech Proprietary   L&T Infotech Confidential   L&T Infotech 
Internal Use Only   L&T Infotech General Business 

This Email may contain confidential or privileged information for the 
intended recipient (s) If you are not the intended recipient, please do 
not use or disseminate the information, notify the sender and delete it 
from your system. 



Chuck Huber <chuck at cehuber.org> 
Sent by: ale-bounces at ale.org
11/05/2007 09:43 PM
Please respond to
Atlanta Linux Enthusiasts <ale at ale.org>


To
ale at ale.org
cc

Subject
[ale] Re: IPv6 programming question






-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ale-request at ale.org wrote:
> Message: 1
> Date: Fri, 02 Nov 2007 13:36:48 -0400

>> int main() 
>> { 
>> int s,r; int ret; 
>> uint16_t val=0; 
>> char *buff; 
>> struct sockaddr_in6 ser; 
>>
>> s = socket(AF_INET6,SOCK_STREAM,PF_INET6); 
>> if ( s <0) 
>>
>>     perror ("socket 6 error"); 
>> else 
>>     /* ser.sin6_addr.s6_addr="fe02::1";  IN6ADDR_ANY_INIT; */ 
>>     ser.sin6_port=htons(2000); 
>>     ser.sin6_family=AF_INET6; 
>>     ser.sin6_flowinfo=0; 
>>     ser.sin6_scope_id=0; 
>>

I assume that there are braces around the else block that are not
posted.  A similar construct is in the server program.  If socket()
fails, you'll get the perror then it'll set the sin6_family and so on,
leaving the sin6_port unset.

>>
>> inet_ntop(int af, const void *src, char *dst, socklen_t cnt */ 
> 
>                I agree with what Jim pointed out.  What's up with the 
line above?

>> while(1) 
>> { 
>> printf("Server waiting :) \n\n "); 
>> consd = accept(s,(struct sockaddr*)&cli,(socklen_t*)&(clilen)); 
> 
>                Accept returns the file descriptor to the accepted 
socket.
> 
>>         if( consd <-1 ) 
>>             perror("accept error"); 
>>         else 
>>         { 
>>         recv(s,buff,sizeof(buff),0); 
> 
>                You're doing a recv on the wrong socket.  You should be 
recv'ing on
> consd.  Socket "s" is your listening socket.

I caught the same thing.  It looks like the braces I pointed out above
have been fixed here.

> 
>>         printf("Received from client data =%s",buff); 
>>         printf("Received from client port =%d",ntohs(cli.sin6_port)); 
>>         break; 
>>         } 
>> } 

Enjoy,
    - Chuck
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHL0FFiR3HaLbYCa4RAiSwAKDeHMT4PYPOBOk+mENgqcCN44t1KwCgtmAc
GMn4adci1tG5FkXlGKxb0fU=
=hfgF
-----END PGP SIGNATURE-----
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale

______________________________________________________________________



______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list