cnaiapi.h头文件

转载:https://zhidao.baidu.com/question/160433286.html 留着怕自己找不着了。

//以下是转载内容:

最后还是自己找到了,就写上来好了,应该有人跟我一样有问题的,貌似要加两个头文件:
第一个:cnaiapi.h


/* cnaiapi.h */

#ifndef _CNAIAPI_H_
#define _CNAIAPI_H_

#if defined(LINUX) || defined(SOLARIS)
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#endif /* defined(LINUX) || defined(SOLARIS) */

#if defined(WIN32)
#include <winsock2.h>
#include "cnaiapi_win32.h"
#endif /* defined(WIN32) */

#include <sys/types.h>

typedef short appnum;
typedef long computer;
typedef int connection;

struct port2sock {
 short port;
 int sock;
};

#define P2S_SIZE 64 /* number of entries in port to socket map table */
#define LISTEN_Q_LEN 5

appnum  appname_to_appnum(char *appname);
computer cname_to_comp(char *cname);
connection await_contact(appnum a);
connection make_contact(computer c, appnum a);
int  send_eof(connection c);
void            cnaiapi_init(void);

#if defined(LINUX) || defined(SOLARIS)
extern pthread_mutex_t await_contact_mutex, cname_mutex, appname_mutex;
#elif defined(WIN32)
extern HANDLE await_contact_mutex, cname_mutex, appname_mutex;
#endif

#endif /* !defined(_CNAIAPI_H_) */

第二个:cnaiapi_win32.h

/* cnaiapi_win32.h */

#include <io.h>
#define read  _read
#define write _write
#define STDIN_FILENO  0
#define STDOUT_FILENO 1

盗链:只有cnaiapi.h没有windows32

/*-------------------------------------------------------------------------------------------*/
 *
 * Program: echoserver
 * Purpose: wait for a connection from an echoclient and echo data
 * Usage:   echoserver <appnum>
 *
 *---------------------------------------------------
 /* cnaiapi.h */

#ifndef _CNAIAPI_H_
#define _CNAIAPI_H_

#if defined(LINUX) || defined(SOLARIS)
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#endif /* defined(LINUX) || defined(SOLARIS) */

#if defined(WIN32)
#include <winsock2.h>
#include <cnaiapi_win32.h>
#endif /* defined(WIN32) */

#include <sys/types.h>

typedef shortappnum;
typedef longcomputer;
typedef intconnection;

struct port2sock {

shortport;
intsock;

};

#define P2S_SIZE 64 /* number of entries in port to socket map table*/
#define LISTEN_Q_LEN 5

appnumappname_to_appnum(char *appname);
computercname_to_comp(char *cname);
connectionawait_contact(appnum a);
connectionmake_contact(computer c, appnum a);
intsend_eof(connection c);
void cnaiapi_init(void);

#if defined(LINUX) || defined(SOLARIS)
extern pthread_mutex_t await_contact_mutex, cname_mutex, appname_mutex;
#elif defined(WIN32)
extern HANDLE await_contact_mutex, cname_mutex, appname_mutex;
#endif

#endif /* !defined(_CNAIAPI_H_) */

转载于:https://www.cnblogs.com/hitWTJ/p/9865443.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值