-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetutils.h
More file actions
96 lines (70 loc) · 2.44 KB
/
netutils.h
File metadata and controls
96 lines (70 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Thomas Pantzer: netutils.h, v0.1b 28.1.98 18:6
*
*
* Copyright 1998 by Thomas Pantzer
*
* Permission to use, copy, modify, and distribute this software for noncommercial
* use and without fee is hereby granted, provided that the above copyright notice
* appear in all copies and that both that copyright notice and this permission
* notice appear in supporting documentation, and that the name of the Author not be
* used in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The Author makes no representations about
* the suitability of this software for any purpose. It is provided "as is"
* without expressed or implied warranty.
*
*
* pantec@aix520.informatik.uni-leipzig.de (Thomas Pantzer)
*
*/
#ifndef _NETUTILS_H
#define _NETUTILS_H
// #ifndef u_long
// #define u_long unsigned long
// #define u_char unsigned char
// #define u_short unsigned short
// #endif
#include "tns_util/porting.h"
#include <sys/types.h>
#ifdef AIX
extern "C" {
extern int socket (int AddressFamily, int Type, int Protocol);
// extern int connect (int Socket,struct sockaddr * Name,int NameLength);
// extern int setsockopt (int Socket, int Level, int OptionName, char *OptionValue, int OptionLength);
extern int shutdown (int Socket, int How);
extern int accept (int Socket,struct sockaddr *Address,int *AddressLength);
// extern int bind (int Socket, struct sockaddr *Name, int NameLength);
extern int listen (int Socket, int Backlog);
}
// #ifdef cplusplus
// #error CPLUSPLUS defined
// #endif
#endif
#if _WINDOWS | WIN32
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#ifndef LINGER_TIMEOUT
#if (__sparc__ || sun || linux || AIX)
#define LINGER_TIMEOUT 6 // 6 seconds
#else
#define LINGER_TIMEOUT 20
#endif
#endif
TNS_UTIL_API int GetTCPPort(char proto[64],int defport);
extern void hostname_str(struct sockaddr_in *client,char *result);
extern char *decIPstring(unsigned long address, char *buffer);
extern void ShutDown(int sd); // extra strong linger shutdown sequence
TNS_UTIL_API void setNonblockingIO(int sd, bool noBlock);
extern int clConnect(char *hname, int port_num, char may_fail);
extern int clConnect_to(char *, int);
extern int svListen(int);
extern int svListen(int,char);
extern int svAccept(int);
//extern void SendMsg(int, char *);
#endif