📄 sockcall.h
字号:
/*
* FILENAME: sockcall.h
*
* Copyright 1997 - 2000 By InterNiche Technologies Inc. All rights reserved
*
*
* MODULE: TCP
*
*
* PORTABLE: yes
*/
/* Additional Copyrights: */
/* Portions Copyright 1996 by NetPort Software. All rights reserved.
* UNIX-ish Sockets library definitions and entry points.
*/
#ifndef _SOCKCALL_H
#define _SOCKCALL_H 1
#define SYS_SOCKETNULL -1 /* error return from sys_socket. */
#define INVALID_SOCKET -1 /* WINsock-ish synonym for SYS_SOCKETNULL */
#define SOCKET_ERROR -1 /* error return from send(), sendto(), et.al. */
#define SOL_SOCKET -1 /* compatability parm for set/get sockopt */
extern long t_socket (int, int, int);
extern int t_bind (long, struct sockaddr *);
extern int t_listen (long, int);
extern long t_accept (long, struct sockaddr *);
extern int t_connect (long, struct sockaddr *);
extern int t_getpeername (long, struct sockaddr *);
extern int t_getsockname (long, struct sockaddr *);
extern int t_setsockopt (long, int, void * );
extern int t_getsockopt (long, int, void * );
extern int t_recv (long, char *, int, int);
extern int t_send (long, char *, int, int);
extern int t_recvfrom (long s, char * buf, int len, int flags, struct sockaddr *);
extern int t_sendto (long s, char * buf, int len, int flags, struct sockaddr *);
extern int t_shutdown (long, int);
extern int t_socketclose (long);
extern int t_errno(long s);
extern char * so_perror(int); /* return an error string for a socket error */
/* define a macro test for validating a passed socket */
#ifndef SOC_CHECK /* ports may replace this test */
#define SOC_RANGE(so) /* null - this version doesn't need range setup */
#define SOC_CHECK(so) \
{ struct socket * tmp; \
for(tmp = (struct socket *)(&soq); tmp; tmp = tmp->next) \
{ if(tmp == so) break; } \
if(tmp != so) \
{ dtrap("sockcall.h \n"); \
return SOCKET_ERROR; \
} \
}
#endif /* undefined SOC_CHECK */
#ifdef SO_SELECT
/* the definitions to support the select() function. These are about
* as UNIX-like as we can make 'em on embedded code. They are also
* fairly compatable with WinSock's select() definitions.
*/
typedef struct fd_set /* the select socket array manager */
{
unsigned fd_count; /* how many are SET? */
long fd_array[FD_SETSIZE]; /* an array of SOCKETs */
} fd_set;
/* our select call - note the traditional "width" parameter is absent */
int t_select(fd_set * in, fd_set * out, fd_set * ev, long tmo_seconds);
/* Select-related functions are calls (not macros) to save space */
void FD_CLR(long so, fd_set * set);
void FD_SET(long so, fd_set * set);
int FD_ISSET(long so, fd_set * set);
/* and one actual macro: */
#define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0)
#endif /* SO_SELECT */
#endif /* _SOCKCALL_H */
/* end of file sockcall.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -