jni 中socket

http://www.cppblog.com/prayer/archive/2008/12/31/70833.html

 

jni 中socket的用法

 

在编写Linux下的网络程序时,使用了sockaddr_in结构,在头文件中声明了<sys/socket.h>, 系统仍不承认sockaddr_in结构,这是为什么? 

#include <netinet/in.h>   

#include <sys/param.h>. p  D+ r! g$ [0 k! F  G5 B; }* m
#include <sys/stat.h>: x7 q# y& F! X2 L0 d
#include <sys/ioctl.h>; ^1 I; }% o" B( {8 ~) c6 H* p) \
#include <sys/socket.h>5 h0 V  H& v2 W+ k3 I
#include <sys/time.h>2 Y4 a8 U) j4 ^2 _8 t7 T1 U
#include <sys/file.h>

#include <netinet/in.h>( p  _0 F, P$ H9 \; A. d
#include <netinet/ip.h>0 \- F& z( \+ ]! i
#include <arpa/ftp.h>
#include <arpa/inet.h>* a( }. Y+ R' @+ u, I
#include <arpa/telnet.h>
9 I& i* A2 N1 V7 ]
#include <stdio.h>
#include <signal.h>4 U" E. v! B) k+ |
#include <string.h>
#include <stdlib.h>
#include <unistd.h>% |4 H# c  x& h6 a" x
#include <errno.h>! @! U0 H- I" h& b0 K1 w
#include <netdb.h>

Feedback

# re: sockaddr_in 结构体在什么头文件中声明  回复  更多评论   

2009-11-01 15:02 by  Pylipala
是在下面这个文件吧:
#include <netinet/in.h>
你已经包含了这个文件了。编译器找不到大概是因为你写的是C文件,但是用的C++的语法。在 sockaddr_in 前面加上 struct 试试。

# re: sockaddr_in 结构体在什么头文件中声明  回复  更多评论   

2011-10-16 12:37 by  ring
我也遇到了这个问题,很是郁闷,楼主如何解决的,能不能留个联系地址,我的邮箱454387468@qq.com望不吝赐教

# re: sockaddr_in 结构体在什么头文件中声明  回复  更多评论   

2011-10-23 10:56 by  高强
@ring 
加上 #include <netinet/in.h>就好了 

# re: sockaddr_in 结构体在什么头文件中声明  回复  更多评论   

2012-11-24 17:46 by  heimu
#include <sys/un.h> 

# re: sockaddr_in 结构体在什么头文件中声明  回复  更多评论   

2013-01-13 21:01 by  皮卡
一楼正解

转载于:https://www.cnblogs.com/changzheng/p/3861751.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值