您的位置:首页 > 理论基础 > 计算机网络

UNIX网络编程第3章套接字编程简介3.2套接字地址结构3.3值结果参数3.4字节排序函数

2015-03-15 12:13 309 查看




















































#include<iostream>
#include"../lib/unpsunyj.h"
intmain(intargc,char**argv)
{
union{
shorts;
charc[sizeof(short)];
}un;
un.s=0x0103;
std::cout<<"un.s=:"<<un.s<<std::endl;
printf("%s:",CPU_VENDOR_OS);
if(sizeof(short)==2)
{
if(un.c[0]==1&&un.c[1]==3)
printf("big-endian\n");
elseif(un.c[0]==3&&un.c[1]==1)
printf("little-endian\n");
else
printf("unknown\n");
}
else
printf("sizeof(short)=%d\n",static_cast<int>(sizeof(short)));
return0;
}


.codearea{color:black;background-color:white;line-height:18px;border:1pxsolid#4f81bd;margin:0;width:auto!important;width:100%;overflow:auto;text-align:left;font-size:12px;font-family:"CourierNew","Consolas","Fixedsys","BitStreamVeraSansMono",courier,monospace,serif}
.codeareapre{color:black;line-height:18px;padding:00012px!important;margin:0em;background-color:#fff!important}
.linewrappre{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;word-break:normal}
.codeareapre.alt{background-color:#f7f7ff!important}
.codearea.lnum{color:#4f81bd;line-height:18px}



















































































































内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: