• 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 皮卡
    一楼正解
  • 相关阅读:
    2.25
    2.24
    2.22
    influxdb 配置
    mongodb 数据备份
    influxDb数据备份
    Linux 及 git 指令集合
    git 项目 保存至gitee中
    TypeScripte 资料
    SecureCrt 的配色方案
  • 原文地址:https://www.cnblogs.com/changzheng/p/3861751.html
Copyright © 2020-2023  润新知