📄 faq.html
字号:
<HTML><HEAD><TITLE>NetProg Homework 6 FAQ</TITLE><LINK rel=stylesheet type="text/css" HREF=../../style/proj.css></HEAD><BODY BGCOLOR=WHITE MARGINHEIGHT=0 MARGINWIDTH=0 TOPMARGIN=0 LEFTMARGIN=0><TABLE bgColor=#8899aa border=0 cellPadding=4 cellSpacing=0 width="100%"> <TR> <TD class=title>  NetProg 2002 HW6 FAQ</TD> </TR><TR BGCOLOR=BLACK><TD CLASS=menu>    <A CLASS=menu HREF=p6.html>Project Description</A>     |   <A CLASS=menu HREF=../submission.html>Submission Instructions</A></TD></TR></TABLE><BR><BR><DIV CLASS=page><CENTER><TABLE WIDTH=90% CELLPADDING=3 BORDER=0 CELLSPACING=0><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>The project description says "your client should be capable of using either IPv4 or IPv6, depending on the server address specified on the command line". does it mean I need to tell the client to use a IPv4 or IPv6 address for itself to connect to the server? for example, when I specify the command like this: <PRE ALIGN=CENTER>./client <serverhost> <server port> 4</PRE> the client should use a IPv4 address for itself, and when the command line is like: <PRE ALIGN=CENTER>./client <server host> <server port> 6</PRE>client should choose IPv6 address instead? is that what you mean? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P> You should not need a command line parameter that specifies what kind of address is being used. The whole idea is to write a generic client that could use any kind of address. Your client should use IPv4 if the server address specified on the command line is an IPv4 address. So if you see this: <PRE ALIGN=CENTER>./client 128.213.4.1 3456</PRE> the client should create an IPv4 socket and give connect (or sendto) a <CODE>sockaddr_in</CODE>. If you see this: <PRE ALIGN=CENTER>./client fe80::a00:20ff:fe82:fa21 3456</PRE> the client should create an IPv6 socket and give connect (or sendto) a <CODE>sockaddr_in6</CODE>. Note that if you use getaddrinfo to create the <CODE>sockaddr</CODE> and determine the value of the parameters you need to create the right socket, you don't need to do anything special to distinguish between the 2 types of addresses - getaddrinfo does all the work! The code could now also work (in the future) with any new address family supported by sockets. </P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>How do I find out the IPv6 address of a machine? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P>On the CS suns you type the comand <CODE>ifconfig -a</CODE> (the full path is <CODE>/usr/sbin/ifconfig</CODE>). On eggbeater it looks like this:</P> <CENTER><TABLE BORDER=1 BGCOLOR=CYAN><TR><TD><PRE>> /usr/sbin/ifconfig -alo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 hme0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 2 inet 128.213.8.24 netmask ffffff00 broadcast 128.213.8.255lo0: flags=2000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6> mtu 8252 index 1 inet6 ::1/128 hme0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2 inet6 fe80::a00:20ff:fe82:fa21/10 </PRE></TD></TR></TABLE></CENTER> <P>This shows that the IPv6 address of eggbeater is <CODE>fe80::a00:20ff:fe82:fa21</CODE> </P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>How do I tell bind to give me any IPv6 address? I tried using INADDR_ANY but it doesn't work with an IPv6 address. </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P> You can initialize a <CODE> struct in6_addr</CODE> to have the value <CODE>IN6ADDR_ANY_INIT</CODE>, then use the resulting in6_addr variable to assign this value in the sockaddr. Example:</P> <PRE> struct in6_addr foo=IN6ADDR_ANY_INIT; struct sockaddr_in6 skadr; ... skadr.sin6_addr = foo; ... </PRE> <P>Note that IN6ADDR_ANY_INIT is legal as an initialization of a variable only, you can't assign it directly to <CODE>skadr.sin6_addr</CODE>! (That's why it's IN6ADDR_ANY_INIT and not IN6ADDR_ANY...).</P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>The project description doesn't say what to do about <EM><insert name of some implementation detail here></EM>. How are we supposed to handle this? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P>You are given lots of freedom to make these decisions yourself, go for it! Just make sure you tell us whatever we need to know to be able to build and run your system! </P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>Is there a demonstration system? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P>No. Dave knows from experience that if a demonstration system was provided, too many people would simply copy his design (instead of coming up with their own). </P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P>What happened with Brittney? </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P>I have no idea. Feel free to make up the rest, send it to me and I'll make it available to others. </P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><!--<TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR><TR BGCOLOR=#ddeeff> <TD VALIGN=TOP CLASS=label>Question:</TD> <TD CLASS=qa><P> </P> </TD></TR><TR BGCOLOR=#ffeedd> <TD VALIGN=TOP CLASS=label>Answer:</TD> <TD CLASS=qa><P> </P> </TD></TR><TR><TD COLSPAN=2><BR> <HR WIDTH=80%><BR></TD></TR>--></TABLE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -