易截截图软件、单文件、免安装、纯绿色、仅160KB

linux setsockopt 没有IPPROTO_TCP吗?(100)

功能:设置客户端链接属性,但是编译的时候发现没有IPPROTO_TCP,而且
提示Error while seting the client socket,意思就算后面的设置也有错误,
C/C++ code:

void set_client_opt(const int client_id)
{
int value=0;
int time = SENDTIMEOUT;
int flag = 1;
struct linger linger_c;

if (client_id <=0)
exit_fatal("Error client id while set the opt");

linger_c.l_onoff = 1;
linger_c.l_linger = 0 ;

/*value += setsockopt(client_id,IPPROTO_TCP,TCP_NODELAY,(const char *)&flag,sizeof(int));*/
value += setsockopt(client_id,SOL_SOCKET,SO_LINGER,(const char *)&linger_c,sizeof(linger_c));
value += setsockopt(client_id,SOL_SOCKET,SO_SNDTIMEO,(const char *)&time,sizeof(time));


if (value < 0)
/*exit_fatal("Error while seting the client socket");*/
printf("Error while seting the client socket\n");
else
printf("Seting the client socket success \n");
}




去man setsockopt 一下,看有没有,如果这没有,那你这版本就是没有这项的了。
有的话再看下他的头文件是不是这个。


引用
引用 1 楼 steptodream 的回复:
头文件加的对吗?
<netinet/in.h>
而不是
<netinet/tcp.h>

setsockopt(client_id,IPPROTO_TCP,


相关问答:

linux环境下gethostbyname函数问题 - C/C++ / C语言

写了个测试程序如下
   
  struct hostent *hp; 
char AlarmDevIP[20];  
  int x2;

hp = gethostbyname("www.google.com");
if (hp)
{ ......

linux下C语言开发oracle的问题。

两个文件1.PC,1.inc
1.PC有操作oracle数据库的 ,1.inc也有操作oracle数据库 
在其他数据中如informix 中$include 1.inc就可以使用了
在ORACLE数据库重 $include 1.inc不可用 EXEC SQL include 1.inc也不可 ......

c语言实现linux time相关函数 - C/C++ / C语言

现在需要在一个嵌入式系统中实现时间函数,编译器未提供time库函数,请问大家如何用c语言实现时间函数啊?
年月日时分秒 到 整数秒(从1970年开始) 之间的相关转换啊
类似mktime 和localtime的功能,谢谢
mktime ......

请大家推荐一本国内作者写的linux编程方面的书

请大家推荐一本国内作者写的linux编程方面的书,最好有串口编程方面的。
在china-pub上搜了搜,也没发现相关的书籍。

国内作者,还真少见!

google上去搜吧 楼主 自己多搜一些对比一下
不过还是推荐读国外的 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号